急着用,有哪位高手会?有木有?
假定time结构包含三个成员:hour、minute和second(都是int类型)。由用户读入从午夜开始的秒数total_sec,请计算出一个等价的时间结构,等价的时间用小时(0 ~23)、分钟(0 ~59)和秒(0 ~59)表示。Enter total seconds:2590
Time:0:43:10
Enter total seconds:39802
Time:11:3:22
#include <stdio.h> struct Time { int hour; int minute; int miao; }; Time fun(Time a,Time b) { Time sum = {0}; int i = 0,j = 0; if((sum.miao = a.miao+b.miao)>=60) { sum.miao %= 60; j = 1; } if((sum.minute = a.minute+b.minute+j)>=60) { sum.minute %= 60; i = 1; } sum.hour += a.hour+b.hour+i; return sum; } int main() { Time a = {0},b = {0}; Time array[100] = {0}; int n = 0; scanf("%d",&n); for(int i = 0;i<2*n;i+=2) { scanf("%d %d %d %d %d %d", &a.hour,&a.minute,&a.miao,&b.hour,&b.minute,&b.miao); array[i] = a; array[i+1] = b; } for(int j = 0;j<2*n;j+=2) { a = fun(array[j],array[j+1]); printf("%d %d %d\n",a.hour,a.minute,a.miao); } return 0; }写过一个比较严密时间加法器 你拿去