|
|
|
@ -0,0 +1,104 @@
|
|
|
|
|
#include<stdio.h>
|
|
|
|
|
#include<stdlib.h> //随机数
|
|
|
|
|
int main() //主函数
|
|
|
|
|
{int a,b,c,i=0,j=0,num=0,k; //j代表分数,
|
|
|
|
|
rule();
|
|
|
|
|
while(1)
|
|
|
|
|
{ a=rand()%50;
|
|
|
|
|
b=rand()%50;
|
|
|
|
|
c=rand();
|
|
|
|
|
if(a<b)
|
|
|
|
|
{ k=a;
|
|
|
|
|
a=b;
|
|
|
|
|
b=k;
|
|
|
|
|
}
|
|
|
|
|
if((a+b)>0&&(a+b)<50)
|
|
|
|
|
{ num++;
|
|
|
|
|
printf("NO.%d ",num);
|
|
|
|
|
j=j+exam(a,b,c);
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
if(i>=10)
|
|
|
|
|
{ great(j);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
printf("==================\n");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
int rule() //定义规则
|
|
|
|
|
{ printf("===============================\n");
|
|
|
|
|
printf("欢迎小朋友来答题,规则如下:\n");
|
|
|
|
|
printf("共有10道题,每题有三次答题机会。\n");
|
|
|
|
|
printf("第一次答对得10分\n");
|
|
|
|
|
printf("第二次答对得7分\n");
|
|
|
|
|
printf("第三次答对得5分,答错不得分.\n");
|
|
|
|
|
printf("下面请开始你的表演!!!\n");
|
|
|
|
|
printf("================================\n");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
int great(int n) //定义成绩等级
|
|
|
|
|
{ printf("你的成绩是%d分\n",n);
|
|
|
|
|
if(n>90)
|
|
|
|
|
printf("SMATE\n");
|
|
|
|
|
else if(n>=80&&n<=90)
|
|
|
|
|
printf("GOOD\n");
|
|
|
|
|
else if(n>=70&&n<80)
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
else if(n>=60&&n<70)
|
|
|
|
|
printf("PASS\n");
|
|
|
|
|
else
|
|
|
|
|
printf("TRY AGAIN\n");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
int exam(int a,int b,int c) //计算得分
|
|
|
|
|
{ int m,n,j=0,i;
|
|
|
|
|
if(c%2==0)
|
|
|
|
|
{ n=a-b;
|
|
|
|
|
printf("%d-%d=",a,b);
|
|
|
|
|
for(i=0;i<3;i++)
|
|
|
|
|
{ scanf("%d",&m);
|
|
|
|
|
if(n==m)
|
|
|
|
|
{ if(i==0)
|
|
|
|
|
j=10;
|
|
|
|
|
else if(i==1)
|
|
|
|
|
j=7;
|
|
|
|
|
else
|
|
|
|
|
j=5;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{ printf(" 答案错误\n");
|
|
|
|
|
if(i<2)
|
|
|
|
|
printf(" 请重新输入:");
|
|
|
|
|
if(i==2)
|
|
|
|
|
printf(" 正确答案是%d\n",n);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(c%2!=0)
|
|
|
|
|
{ n=a+b;
|
|
|
|
|
printf("%d+%d=",a,b);
|
|
|
|
|
for(i=0;i<3;i++)
|
|
|
|
|
{ scanf("%d",&m);
|
|
|
|
|
if(m==n)
|
|
|
|
|
{ if(i==0)
|
|
|
|
|
j=10;
|
|
|
|
|
else if(i==1)
|
|
|
|
|
j=7;
|
|
|
|
|
else
|
|
|
|
|
j=5;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{ printf(" 答案错误\n");
|
|
|
|
|
if(i<2)
|
|
|
|
|
printf(" 请重新输入:");
|
|
|
|
|
if(i==2)
|
|
|
|
|
printf(" 正确答案是%d\n",n);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
printf("__________________\n");
|
|
|
|
|
return j;
|
|
|
|
|
}
|