#include<stdio.h>
struct my_time
{
int hour;
int minutes;
int seconds;
int haos;
};
void delay()
{
long int i;
for(i=-2*1023000;i<2*1023000;i++);
}
void update(struct my_time *t)
{
t->haos++;
if(t->haos==100)
{
t->haos=0;
t->seconds++;
}
if(t->seconds==60)
{
t->seconds=0;
t->minutes++;
}
if(t->minutes==60)
{
t->minutes=0;
t->hour++;
}
if(t->hour==24)
t->hour=0;
delay();
}
void display(struct my_time *t)
{
printf("%2d:%2d:%2d:%2d\r",t->hour,t->minutes,t->seconds,t->haos);
}
void main()
{
struct my_time time;
time.hour=0;
time.minutes=0;
time.seconds=0;
time.haos=0;
while(1)
{
update(&time);
display(&time);
}
}
请各位大神改一改
[
本帖最后由 ZZZSS00 于 2014-6-6 22:42 编辑 ]