#include<stdlib.h>
#include<time.h>
void main()
{ int a,b,i,c,d,p=1,m=0,n=0
a=rand()%100b=rand()%100
for(i=0i<10i++)
printf("*")
printf("\n* 1.加法 *\n")
printf("\n* 2.减法 *\n")
printf("\n* 3.乘法 *\n")
printf("\n* 4.除法 *\n")
for(i=0i<10i++)
printf("*")
while(p)
{ printf("\n请选择 *** 作n(1-6):")
scanf("%d",&c)
c=c%6
switch(c)
{ case 0:exit(1)
case 1:c='+'printf("%d+%d=\n",a,b)scanf("%d",&d)
while(m<3&&p)
{if(d==a+b)<br/>{printf("good,你的答案是正确的")<br/> n++p=0}
else
printf("\n对不起,你的答案是错误的\n请输入正确答案:\n%d+%d=\n",a,b)
m++scanf("%d",&d) } p=1
break
case 2:c='-'printf("%d-%d=\n",a,b)
scanf("%d",&d)
while(m<3&&p)
{if(d==a-b)<br/>{printf("good,你的答案是正确的")<br/> n++p=0}
else
printf("\n对不起,你的答案是错误的\n请输入正确答案:\n%d-%d=\n",a,b)
m++scanf("%d",&d)} p=1
break
case 3:c='*'printf("%d*%d=\n",a,b)
scanf("%d",&d)
while(m<3&&p)
{if(d==a*b)<br/>{printf("good,你的答案是正确的")<br/> n++p=0}
else
printf("\n对不起,你的答案是错误的\n请输入正确答案:\n%d*%d=\n",a,b)
m++scanf("%d",&d)} p=1
break
case 4:c='/'printf("%f/%f=\n",(float)a,(float)b)
scanf("%d",&d)
while(m<3&&p)
{if(d==(float)a/(float)b)<br/>{printf("good,你的答案是正确的")<br/> n++p=0}
else
printf("\n对不起,你的答案是错误的\n请输入正确答案:\n%d-%d=\n",a,b)
m++scanf("%d",&d)} p=1break
case 5:printf("\n你一共做对了%d,错了%d\n",n,m)break
}
}
}
<pre t="code" l="cpp">right_prompt(){
int x
x = rand()%4+1
switch(x) {
case 1:
printf("Very Good!\n")
break
case 2:
printf("Excellent!\n")
break
case 3:
printf("Nice work!\n")
break
case 4:
printf("Keep up the good work!\n")
break
}
}
wrong_prompt()
{
int x
x = rand()%4+1
switch(x) {
case 1:
printf("No. Please try again.\n")
break
case 2:
printf("Wrong. Try once more.\n")
break
case 3:
printf("Don’t give up!\n")
break
case 4:
printf("Not correct. Keep trying.\n")
break
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)