|
|
发表于 2011-5-7 16:38:55
|
显示全部楼层
本帖最后由 soldier 于 2011-5-9 16:12 编辑
- #include <stdio.h>
- #include <iostream>
- using namespace std;
- struct time
- {
- int hour;
- int minutes;
- int seconds;
- };
- struct time timeupdate ( struct time nows )
- {
-
- ++nows.seconds;
- if ( nows.seconds == 60 )
- {
- nows.seconds = 0;
- ++nows.minutes;
- }
-
- if ( nows.minutes == 60)
- {
- nows.minutes = 0;
- ++nows.hour;
- }
- if ( nows.hour == 24 )
- {
- nows.hour = 0;
- }
- return nows;
- }
- int main (void)
- {
- struct time timeupdate(struct time now);
-
- struct time testtimes[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].minutes,
- testtimes[i].seconds
- );
- testtimes[i] = timeupdate (testtimes[i]);
- printf ("...one second later it's %.2i:%.2i:%.2i\n",
- testtimes[i].hour,
- testtimes[i].minutes,
- testtimes[i].seconds
- );
- }
-
- system("pause");
- return 0;
- }
复制代码 //不知道楼主要的是不是这个意思 |
|