• 3点55再过1小时22分钟是多少呢?


    方法1

    include<stdio.h>

    main()
    {
    int hour = 3;
    int min = 55;

    int pass_hour = 1;
    int pass_min = 22;
    int new_hour;
    int new_min;
        new_hour = hour + pass_hour + (min + pass_min)/60;
    new_min = (min + pass_min) % 60;
    printf("%d:%d
    ",new_hour , new_min);
    

    }

    方法2

    include<stdio.h>

    main()
    {
    int hour = 3;
    int min = 55;

    int pass_hour = 1;
    int pass_min = 22;
    int new_hour;
    int new_min;
        if(min + pass_min >= 60)
    {
    	new_min = min + pass_min - 60;
    	new_hour = hour + pass_hour + 1;
    }
    
    if(min + pass_min < 60)
    {
    	new_min = min + pass_min;
    	new_hour = hour + pass_hour;
    }
    
    printf("%d:%d
    ", new_hour , new_min);
    

    }

    方法3:(利用结构体封装)

    include<stdio.h>

    struct time add(struct time now, struct time pass);

    struct time{
    int hour;
    int min;
    };

    main()
    {
    struct time now = {3, 55}, pass = {1, 33}, result;

    result = add(now, pass);
    
    printf("%d:%d
    ", result.hour, result.min);
    

    }

    struct time add(struct time now, struct time pass)
    {
    struct time rel;
    rel.hour = now.hour + pass.hour + (now.min + pass.min)/60;
    rel.min = (now.min + pass.min)%60;

    return rel;
    

    }

  • 相关阅读:
    TuShare接口适应
    任泽平金句记录
    分红送股---要注意的两个日期
    解决github无法登录的问题
    持久斗争
    正则语法
    JWT的结构
    付鹏的黄金分析框架
    vscode设置背景图片
    Ubuntu 16.04安装Nginx
  • 原文地址:https://www.cnblogs.com/aloe218/p/13083522.html
Copyright © 2020-2023  润新知