#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{
int a,b,numOfQues=0,numOfRight=0;
char inquiry;
srand(time(NULL));
printf("欢迎你来做一位数的加减乘除法\n");
do
{
fflush(stdin);
int temp=rand()%4;
a=rand()%10;
b=rand()%10;
switch(temp)
{
case 0:
{
int ans;
printf("%d+%d=",a,b);
scanf("%d",&ans);
if(ans==a+b)
{
numOfRight++;
printf("正确\n");
} else
printf("错误\n");
break;
}
case 1:
{
int ans;
printf("%d-%d=",a,b);
scanf("%d",&ans);
if(ans==a-b)
{
numOfRight++;
printf("正确\n");
}else
printf("错误\n");
break;
}
case2:
{
int ans;
printf("%d*%d=",a,b);
scanf("%d",&ans);
if(ans==a*b){
numOfRight++;
printf("正确\n");
}else
printf("错误\n");
break;
}
}
case 3:
{
if(b==0||(a%b!=0))continue;
int ans;
printf("%d / %d=",a,b);
scanf("%d",&ans);
if(ans==a/b)
{
numOfRight++;
printf("正确\n");
}else
printf("错误\n");
break;
}
numOfQues++;
printf("你还要做吗(N表示不要");
scanf("%d",inquiry);
}while(!('N'==inquiry||'n'==inquiry));
printf("你的正确率为%d,再见",numOfRight*100/numOfQues);
return 0;
}