输入开始时间:
Please input hour-clock(12 25 20): 1 20 20
Please input seconds(1200): 10000
输出结果:
New Time : 04:07:00
#include <stdio.h>
#include <string.h>
typedef struct clock{
int hour;
int minute;
int second;
}Clock;
int main()
{
Clock clk;
printf("Please input hour-clock(12 25 20): ");
scanf("%d %d %d", &clk.hour, &clk.minute, &clk.second);
int seconds;
printf("Please input seconds(1200): ");
scanf(" %d", &seconds);
clk.second += seconds;
while( clk.second>=60 ){
clk.minute++;
clk.second -= 60;
}
while( clk.minute>=60 ){
clk.hour++;
clk.minute -= 60;
}
while( clk.hour>=24 ){
clk.hour -= 24;
}
printf("New Time : %02d:%02d:%02d", clk.hour, clk.minute, clk.second);
return 0;
}