首页 > 试题广场 >

下列程序读入时间数值,将其加1秒后输出,时间格式为:hh:

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

&((&time)->hour),&((&time)->minute),&((&time)->second)
time.second
time.minute++
time.hour == 24
发表于 2019-06-17 16:33:45 回复(0)