third commit

master
AQ123456789 6 years ago
commit 47114d1c03

@ -0,0 +1,64 @@
#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;
int daan,fenshu=0;
for(i=0;i<10;i++)
{
srand( (unsigned)time( NULL ));
b=rand()%50;
c=rand()%50;
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;} //判断算式是否符合要求
printf("\t%d%c%d=?\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("%d\n",daan);break;}
} //判断得分或输出该算式答案
}
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;
}
Loading…
Cancel
Save