题解 | 牛牛的时钟
牛牛的时钟
https://www.nowcoder.com/practice/36fd5f6b6236452f99f0ea59cd3447e0
#include <stdio.h> typedef struct TIME { int h; int m; int s; }time; int main() { int n=0; scanf("%d",&n); time t; t.h=0; t.m=0; t.s=0; for (int i=0;i<n;i++) { int s=0; int s1=0; int m1=0; int h1=0; scanf("%d",&s); s1=t.s+s; if(s1>=60) { t.s = s1 % 60; m1 = t.m + s1 / 60; if(m1>=60) { t.m = m1 % 60; t.h = t.h + m1 / 60; } else { t.m=m1; } } else { t.s = s1; } printf("%d %d %d\n",t.h,t.m,t.s); } return 0; }