发布网友 发布时间:2022-04-22 01:29
共1个回答
热心网友 时间:2023-09-23 16:35
#include <stdio.h>
#include <time.h>
main(){
int a,b,ans,guess,n=0,chance;
char opr='+';
srand(time(NULL));
do{
a=rand()%20+1;
b=rand()%30+1;
n++;
if(n%2==0){
ans=a+b;
opr='+';
}else{
ans=a-b;
opr='-';
}
chance=3;
do{
printf("Q:%i%c%i=?",a, opr, b);
scanf("%i",&guess);
if(ans == guess)
printf("Excellent\n");
else
printf("Try again\n");
}while(ans!=guess && --chance);
}while(1);
}