|
|
#include<stdio.h>
|
|
|
#include<stdlib.h>
|
|
|
#include<time.h>
|
|
|
int jiaf(int a,int b) //加法题目
|
|
|
{ int c;
|
|
|
printf("%d+%d=\n",a,b);
|
|
|
scanf("%d",&c);
|
|
|
if(c==(a+b))return 1;
|
|
|
else return 0;
|
|
|
}
|
|
|
int jianf(int a,int b) //减法题目
|
|
|
{ int c;
|
|
|
printf("%d-%d=\n",a,b);
|
|
|
scanf("%d",&c);
|
|
|
if(c==(a-b))return 1;
|
|
|
else return 0;
|
|
|
}
|
|
|
int text()
|
|
|
{int a,b,d,i,j,g=0,m,result,agan,gard=0; //a,b为随机数,d为随机加减法,i,j为循环数,m为判断是否开始作答,result为判断答案是否正确,agan为二三次输入的答案。
|
|
|
while(1) //判断是否准备考试
|
|
|
{ if(g==3)
|
|
|
printf("不要乱玩,若再一次则考试结束!!!\n");
|
|
|
if(g==4)
|
|
|
break;
|
|
|
printf("请确定是否开始作答!!!\n");
|
|
|
printf("开始作答输入1\n");
|
|
|
printf("还没想好输入2\n"); //备注,提示工作
|
|
|
scanf("%d",&m);
|
|
|
if(m==1)
|
|
|
{ printf("请做好准备!\n");
|
|
|
printf("一共十道题,可做三次\n");
|
|
|
printf("________________________\n");
|
|
|
break;
|
|
|
}
|
|
|
else
|
|
|
{g++;
|
|
|
continue;
|
|
|
}
|
|
|
}if(g!=4)
|
|
|
{ srand((int)time(NULL));
|
|
|
for(i=1;i<=10;i++) //开始出题
|
|
|
{ while(1)
|
|
|
{ a=0+(rand()%51);
|
|
|
b=0+(rand()%51);
|
|
|
if((a+b)>50||(a-b)<0||(b-a)<0)
|
|
|
continue;
|
|
|
else
|
|
|
break;
|
|
|
}
|
|
|
d=1+(rand()%2);
|
|
|
printf("第%d题:",i);
|
|
|
switch(d)
|
|
|
{ case 1:result=jiaf(a,b);
|
|
|
if(result==1)
|
|
|
{ printf("正确\n"); //回答正确加十分
|
|
|
gard+=10;
|
|
|
break;}
|
|
|
else
|
|
|
{ for(j=1;j<=3;j++) //回答错误,依次加七分,五分,零分
|
|
|
{ if(j==3)
|
|
|
{ printf("你的次数已用完\n");
|
|
|
printf("该题的正确答案为:%d\n",a+b);
|
|
|
break;
|
|
|
}
|
|
|
else
|
|
|
{ printf("错误\n");
|
|
|
printf("请重新输入\n");
|
|
|
scanf("%d",&agan);
|
|
|
if(agan==(a+b))
|
|
|
{printf("正确\n");
|
|
|
break;
|
|
|
}
|
|
|
else
|
|
|
continue;
|
|
|
}
|
|
|
}switch(j){
|
|
|
case 1:gard+=7;
|
|
|
break;
|
|
|
case 2:gard+=5;
|
|
|
break;
|
|
|
case 3:gard+=0;
|
|
|
break;
|
|
|
}
|
|
|
break;}
|
|
|
case 2:result=jianf(a,b);
|
|
|
if(result==1)
|
|
|
{ printf("正确\n");
|
|
|
gard+=10;
|
|
|
break;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
for(j=1;j<=3;j++)
|
|
|
{ if(j==3)
|
|
|
{ printf("你的次数已用尽\n");
|
|
|
printf("该题的正确答案为:%d\n",a-b);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{ printf("错误\n");
|
|
|
printf("请重新输入\n");
|
|
|
scanf("%d",&agan);
|
|
|
if(agan==(a-b)) ))
|
|
|
{ printf("正确\n");
|
|
|
break;
|
|
|
}
|
|
|
else
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
}switch(j){
|
|
|
case 1:gard+=7;
|
|
|
break;
|
|
|
case 2:gard+=5;
|
|
|
break;
|
|
|
case 3:gard+=0;
|
|
|
break;
|
|
|
}
|
|
|
break;}
|
|
|
}
|
|
|
}}printf("你的成绩为:%d\n",gard);
|
|
|
if(gard>90)printf("你的评价为:SMART\n"); //评价
|
|
|
else if(gard>=80&&gard<=90)printf("你的评价为:GOOD\n");
|
|
|
else if(gard>=70&&gard<80)printf("你的评价为: OK\n");
|
|
|
else if(gard>=60&&gard<70)printf("你的评价为:PASS\n");
|
|
|
else (gard<60)printf("考试结束,你的评价为:TRY AGAIN\n");}
|
|
|
int main()
|
|
|
{ text();
|
|
|
return 0;
|
|
|
} |