下列程序读入时间数值,将其加1秒后输出,时间格式为:hh: mm: ss,即“小时:分钟:秒”,当小时等于24小时,置为0。
#include <stdio.h>
struct {
int hour, minute, second;
} time;
int main(void)
{
scanf("%d:%d:%d", );
time.second++;
if( == 60){
;
time.second = 0;
if(time.minute == 60){
time.hour++;
time.minute = 0;
if( )
time.hour = 0;
}
}
printf ("%d:%d:%d\n", time.hour, time.minute, time.second );
return 0;
}