题解 | #牛牛的时钟#

牛牛的时钟

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

#include <stdio.h>
struct Time{
    int h;
    int m;
    int s;
};
int main() {
    int n=0;
    scanf("%d",&n);
    int arr[10];
    for(int i=0;i<n;i++)
        scanf("%d",&arr[i]);
    struct Time time[10]={0};
    for(int i=0;i<n;i++)
    {
        if(i>0)
        {
            time[i].h=time[i-1].h;
            time[i].m=time[i-1].m;
            time[i].s=time[i-1].s;
        }
        time[i].s+=arr[i];
        if(time[i].s>=60)
        {
            time[i].m+=time[i].s/60;
            time[i].s=time[i].s%60;
        }
        if(time[i].m>=60)
            {
                time[i].h+=time[i].m/60;
                time[i].m=time[i].m%60; 
            }
        printf("%d %d %d\n",time[i].h,time[i].m,time[i].s);
    }
    return 0;
}

全部评论

相关推荐

码农索隆:传音老登来也。 但是这个我不知道怎么回答,不仅仅传音吧,很多公司在候选人不第一时间接受offer或主动将报道时间延期时,都会再从池子里面捞人,直到l捞到满足公司所有要求的人。
秋招的第一个offer,...
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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