#include?<stdlib.h>
#include?<time.h>
int?score=0;
int?count=1;
void?func()
{
int?answer=1;
int?a,b,c,opration,input;
while(1)
{
a=rand()%49+1;
b=rand()%49+1;
opration=rand()%2;?//0:+1:-
if(opration==0)
{
if(a+b>50)
{
continue;
}
else
{
c=a+b;
break;
}
}
else
{
if(a-b<0)
{
int?t=a;
a=b;
b=t;
}
c=a-b;
break;
}
}
while(answer<=3)
{
if(opration==0)
{
printf("\n第%d題:?%d?+?%d?=?",count,a,b);
}
else
{
printf("\n第%d題:?%d?-?%d?=?",count,a,b);
}
fflush(stdin);
scanf("%d",&input);
if(c==input)
{
switch(answer)
{
case?1:
score+=10;
break;
case?2:
score+=7;
break;
case?3:
score+=5;
break;
}
count++;
return;
}
else
{
if(answer==3)
{
printf("\n三次回答錯誤,?正確答案為:?%d\n",c);
count++;
return;?
}
printf("\n錯誤,?請重新輸入!\n");
answer++;
}
}
}
int?main()
{
srand((unsigned)time(0));
int?i;
for(i=0;i<10;i++)
{
func();
}
printf("\n\n妳的成績為:?%d",score);
switch(score/10)
{
case?10:
case?9:
printf("?SMART");
break;
case?8:
printf("?GOOD");
break;
case?7:
printf("?OK");
break;
case?6:
printf("?PASS");
break;
default:
printf("?AGAIN");
break;
}
return?0;
}