如何在C语言中控制秒表停止呢
开始计时后,你随便按一个键它stop,再随便按一个键它接着计时。可以在线讨论一下。#include#includevoiddelay(intn);unsignedcharh1,h2,m1,m2,s1,s2,w1,w2;voidmain(){chark;chartmp;printf("PleaseinputSorstostartthetimer:");scanf("%s",&k);/*输入‘s’或者‘S’开始计时;*/h1=h1=m1=m2=s1=s2=w1=w2=0;if(k=='s'||k=='S'){while(1){while(!bioskey(1)){printf("time:%d%d:%d%d:%d%d:%d%d",h1,h2,m1,m2,s1,s2,w1,w2);delay(2900);w2;if(w2>9){w1;w2=0;}if(w1>5){s2;w1=0;}if(s2>9){s1;s2=0;}if(s1>5){m2;s1=0;}if(m2>9){m1;m2=0;}if(m1>5){h2;m1=0;}if(h2>3){h1;h2=0;}if(h1>2){printf("Tothemaxvalue,itcouldn'tgoonanymore!
");break;}}tmp=bioskey(0);printf("time:%d%d:%d%d:%d%d:%d%d",h1,h2,m1,m2,s1,s2,w1,w2);while(!bioskey(1));tmp=bioskey(0);}}elseprintf("Inputerror!Pleaseinputagain:
");}voiddelay(intn){inti,j;for(i=0;i