题解 | #牛牛的时钟#

牛牛的时钟

https://www.nowcoder.com/practice/36fd5f6b6236452f99f0ea59cd3447e0

#include <csetjmp>
#include <iostream>

using namespace std;

int main() {

    int time = 0, num = 0;

    cin >> num;

    int s = 0, m =0 , h =0;

    for( int i = 0 ; i < num ;  i++){

        cin >> time;

        s+= time;

        while(s >= 60) {
           s-=60; 
           m++;
        }
        while(m >= 60) {
           m-=60; 
           h++;
        }
        while(h >= 24) {
           h-=24; 
        }    

        cout << h << " " << m << " " << s << endl;      
    }

    return 0;
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务