周杰伦的偶像是谁:有一个很急的问题希望大家帮忙?

来源:百度文库 编辑:查人人中国名人网 时间:2024/05/06 04:46:47
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <dos.h>
struct tm { int minutes,seconds,cents;};

void Delay()
{ long int t;
for(t=1;t<=11128000;++t);

}

void update(struct tm *t)
{ (*t).cents++;
if ((*t).cents==100) {
(*t).cents=0;
(*t).seconds++;
}
if ((*t).seconds==60) {
(*t).seconds=0;
(*t).minutes++;
}
if((*t).minutes==60) (*t).minutes=0;
Delay();
}
void display(struct tm *t)
{
system("cls");
printf("%d:",(*t).minutes);
printf("%d:",(*t).seconds);
printf("%d\n",(*t).cents);
printf("Now, press 'e' key to stop the clock...");
}

int main()
{ char m;
struct tm time;
time.minutes=time.seconds=time.cents=0;
printf("Now, press 'S' key to begin the clock...\n");
m=getche();
if(m=='S'||m=='s')
while(!kbhit())
{ update(&time);
display(&time);
printf("Only 's' or 'S' can be inputed!!");
}

getch();

}

怎么让这个秒表程序,只按S开始,按E结束或暂停呢?谢了!