#include<bits/stdc++.h>
using namespace std;
struct time{
int hour;
int minutes;
int seconds;
}
struct time timeUpdate(struct time now);
int main(){
struct time testTimes[5] = {{11,59,59},{10,9,59},{9,9,59},{8,59,59},{23,59,59}};
int i;
for( i = 0; i < 5; i++){
printf("time is %d:%d:%d\n",testTimes[i].hour,testTimes[i].minutes,testTimes[i].seconds);
testTimes[i] = timeUpdate(testTimes[i]);
printf("now time is %d:%d:%d\n",testTimes[i].hour,testTimes[i].minutes,testTimes[i].seconds);
}
return 0;
}
struct time timeUpdate(struct time now){
//一秒钟过后
++now.seconds;
if(now.seconds == 60){
now.minutes += 1;
now.seconds = 0;
}
if(now.minutes == 60){
now.hour += 1;
now.minutes = 0;
}
if(now.hour == 24){
now.hour = 0;
}
return now;
}
一分钟后的时间 C
最新推荐文章于 2022-07-21 19:58:23 发布