You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
2.0 KiB
69 lines
2.0 KiB
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <time.h>
|
|
|
|
int sjfu()
|
|
{ srand( (unsigned)time( NULL ));
|
|
return rand()%2;
|
|
}
|
|
int main()
|
|
{
|
|
char a[]={'+','-'};
|
|
int b,c,d,t,i,j,f,su=0;
|
|
int daan,fenshu=0;
|
|
printf("--------------------------------------------------------------\n");
|
|
printf("\n\t请输入以下10个计算题的答案\n\t(别着急,每个题有三次输入的机会哦)\n\n");
|
|
printf("--------------------------------------------------------------\n\n");
|
|
for(i=0;i<10;i++)
|
|
{
|
|
srand( (unsigned)time( NULL ));
|
|
b=rand()%51;
|
|
c=rand()%51;
|
|
d=sjfu();
|
|
if(b<c)
|
|
{ t=b;b=c;c=t;}
|
|
|
|
switch(a[d])
|
|
{
|
|
case '+':{daan=b+c;break;}
|
|
case '-':{daan=b-c;break;}
|
|
} //得出算式答案
|
|
|
|
if(daan>50)
|
|
{ i-=1;continue;} //判断算式是否符合要求
|
|
su=i;
|
|
printf("第%d题\n",su+1);
|
|
printf("\t%d%c%d=?\n\n",b,a[d],c); //输出算式题
|
|
|
|
|
|
for(j=0;j<3;j++)
|
|
{
|
|
scanf("%d",&f);
|
|
if(f==daan)
|
|
break;
|
|
else
|
|
printf("答案不对哦,再想想看\n");
|
|
} //用户输入答案(三次机会)
|
|
|
|
switch(j)
|
|
{
|
|
case 0:{fenshu+=10;break;}
|
|
case 1:{fenshu+=7;break;}
|
|
case 2:{fenshu+=5;break;}
|
|
case 3:{fenshu+=0;printf("\n\t很可惜\n\t正确答案是 %d\n",daan);break;}
|
|
} //判断输出该算式答案,并计算得分
|
|
printf("\n--------------------------------------------------------------\n\n");
|
|
}
|
|
if(fenshu>=90)
|
|
printf("SMART\n");
|
|
else if(fenshu<90&&fenshu>=80)
|
|
printf("GOOD\n");
|
|
else if(fenshu<80&&fenshu>=70)
|
|
printf("OK\n");
|
|
else if(fenshu<70&&fenshu>=60)
|
|
printf("PASS\n");
|
|
else
|
|
printf("TRY AGAIN\n"); //判断等级
|
|
return 0;
|
|
}
|