#include <stdio.h>
struct time{
int hour;
int minutes;
int seconds;
};
struct time timeUpdate(struct time now);
int main(void)
{
struct time testTime[5] = {
{11,59,59},{12,0,0},{1,29,59},{23,59,59},{19,12,27}
};
int i;
for(i = 0; i < 5; ++i){
printf("Time is %.2i:%.2i:%.2i",
testTimes[i].hour,testTimes[i].mintues,testTimes[i].seconds);
timeTimes[i] = timeUpdate(timeTimes[i]);
printf("... one second later it's %.2i:%.2i:%.2i\n",
testTimes[i].hour,testTime[i].minutes,testTime[i].seconds);
}
return 0;
}
struct time timeUpdate(struct time now)
{
++now.seconds;
if(now.second == 60){
noe.seconds = 0;
++now.minutes;
if(now.minutes == 60){
now.minutes = 0;
++now.hour;
}
if(now,hour == 24){
now.hour = 0;
}
}
}
----------------------------2
于 2022-04-05 21:02:15 首次发布