习题9-1 时间换算
Posted 2018jason
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了习题9-1 时间换算相关的知识,希望对你有一定的参考价值。
1 #include <stdio.h> 2 3 struct time 4 { 5 int hour; 6 int minute; 7 int second; 8 }; 9 int main(void) 10 { 11 int n, temp; 12 struct time t1; 13 14 scanf("%d:%d:%d", &t1.hour, &t1.minute, &t1.second); 15 scanf("%d", &n); 16 17 t1.second = t1.second + n; 18 temp = t1.second / 60; 19 t1.second = t1.second % 60; 20 21 t1.minute = t1.minute + temp; 22 temp = t1.minute / 60; 23 t1.minute = t1.minute % 60; 24 25 t1.hour = t1.hour + temp; 26 t1.hour = t1.hour % 24; 27 28 printf("%02d:%02d:%02d ", t1.hour, t1.minute, t1.second); 29 30 return 0; 31 }
以上是关于习题9-1 时间换算的主要内容,如果未能解决你的问题,请参考以下文章