1 #include <stdio.h> 2 3 struct myTime 4 { 5 int h; 6 int m; 7 int s; 8 }; 9 10 int main() 11 { 12 struct myTime T; 13 int h,m,s; 14 printf("输入小时:"); 15 scanf("%d",&h); 16 printf("输入分钟:"); 17 scanf("%d",&m); 18 printf("输入秒:"); 19 scanf("%d",&s); 20 T.h=h; 21 T.m=m; 22 T.s=s; 23 if (s==59) 24 { 25 T.s=0; 26 T.m++; 27 if (T.m==60) 28 { 29 T.m=0; 30 T.h++; 31 if (T.h==24) 32 { 33 T.h=0; 34 } 35 } 36 } 37 else 38 { 39 T.s++; 40 } 41 printf("时间%d:%d:%d加1秒后等于%d:%d:%d\n",h,m,s,T.h,T.m,T.s); 42 return 0; 43 }