
while(1)
{
if( key==0)//按键按下
{
cnt++
if( cnt>300)
{
cnt=0//到3秒,退出本循环进入下一段程序
break
}
dely(10)//延时10毫秒
}
}
while(1)
{
...//此为主程序段
}
//---------------------------------------------------------------------------#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <time.h>
#define SP 32
#define ESC 27
int main(void)
{
int a,b,fg
char ch
srand(time(NULL))
do
{
a=rand()%9000+1000
b=rand()%9000+1000
fg=0
printf("%d+%d=",a,b)
while (fg<3)
{
ch=getch()
if (ch==SP&&!fg) {
printf("%d\n",a+b)
fg=1
}
else if (ch==SP&&fg==1) {
system("cls")
break
}
else if (ch==ESC) {
break
}
}
}while (ch!=ESC)
return 0
}
//---------------------------------------------------------------------------
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)