#include//结构体,并起别名typedef struct student{ int second; int minute; int hour;};void Update(struct student *p);void Display(struct student *p);void Delay();//主函数int main(){ //long i; struct student a,*p; a.second=-1; a.minute=0; a.hour=0; p=&a; Update(p); return 0;}//时间更新,并判断是否在正常值以内void Update(struct student *p){ struct student a; while (p->second<61) {if (p->second>=59) { p->second=p->second-60; p->minute=p->minute+1; } if (p->minute>=59) { p->minute=p->minute-60; p->hour=p->hour+1; } if (p->hour>=23) p->hour=p->hour-24; p->second=p->second+1; Display(p); Delay(); }}//输出时间void Display(struct student *p){ printf ("%2d:%2d:%2d\r",p->hour,p->minute,p->second);}//时间更新一秒,进行300000000次空语句循环void Delay(){ long h=0; while (h!=300000000) {h++; }}