#include<stdio.h>#include<string.h>#include<stdlib.h>struct time{?int hour;?int minute;?int second;};struct time TimeUpdate(struct time now);int main(int argc,char const argv[]){?int i;?struct time testtimes[5]={{23,59,59},{12,52,36},{06,12,58},{00,00,00},{25,01,26}};?for(i=0;i<5;i++)?{?printf("Time is %02d:%02d:%02d\n",testtimes[i].hour ,testtimes[i].minute ,testtimes[i].second );?testtimes[i]=TimeUpdate(testtimes[i]);?printf("...one second after the now time is %02d:%02d:%02d\n",testtimes[i].hour ,testtimes[i].minute ,testtimes[i].second);?getchar(); ?}?return 0;}struct time TimeUpdate(struct time now){?if(now.hour>=0&&now.hour<24)?{??if(now.second>=60)??{???now.minute=now.minute +now.second /60;???now.second=now.second-60*(now.second/60);??????? if(now.minute>=60)???? {???? now.hour=now.hour+now.minute/60;???? now.minute=now.minute-60*(now.minute/60);???? }??}??printf("您輸入的標(biāo)準(zhǔn)時(shí)間格式是 %02d:%02d:%02d\n",now.hour,now.minute ,now.second );??++now.second;??if(now.second ==60)??{???now.second=0;???++now.minute;???if(now.minute==60)???{????now.minute=0;????++now.hour;????if(now.hour==24)????{?????now.hour =0;????}???}??}????}?else?{??printf("時(shí)間輸入有誤!\n");?}}
- 2 回答
- 0 關(guān)注
- 1554 瀏覽
添加回答
舉報(bào)
0/150
提交
取消