#include "stdio.h"
#include "stdlib.h"
#include "time.h"
int main()
{
x09int i,j,a,b,c,ans,ans1,score=0;
x09float ans2;
x09for(i=0;i<10;i++)
x09{
x09x09srand(time(0));
x09x09a=rand()%9+1;
x09x09b=rand()%9+1;
x09x09c=rand()%3;
x09x09switch(c)
x09x09{
x09x09case 0:
x09x09x09ans=a+b;
x09x09x09printf("%d+%d=?n",a,b);
x09x09x09scanf("%d",&ans1);
x09x09x09for(j=0;j<2;j++)
x09x09x09{
x09x09x09x09if(ans1==ans)
x09x09x09x09{
x09x09x09x09x09score+=10;
x09x09x09x09x09printf("Good!n");
x09x09x09x09x09break;
x09x09x09x09}
x09x09x09x09else
x09x09x09x09{
x09x09x09x09x09printf("Wrong,Try Again!n");
x09x09x09x09x09scanf("%d",&ans1);
x09x09x09x09}
x09x09x09}
x09x09x09break;
x09x09case 1:
x09x09x09ans=a-b;
x09x09x09printf("%d-%d=?n",a,b);
x09x09x09scanf("%d",&ans1);
x09x09x09for(j=0;j<2;j++)
x09x09x09{
x09x09x09x09if(ans1==ans)
x09x09x09x09{
x09x09x09x09x09score+=10;
x09x09x09x09x09printf("Good!n");
x09x09x09x09x09break;
x09x09x09x09}
x09x09x09x09else
x09x09x09x09{
x09x09x09x09x09printf("Wrong,Try Again!n");
x09x09x09x09x09scanf("%d",&ans1);
x09x09x09x09}
x09x09x09}
x09x09x09break;
x09x09case 2:
x09x09x09ans=a*b;
x09x09x09printf("%d*%d=?n",a,b);
x09x09x09scanf("%d",&ans1);
x09x09x09for(j=0;j<2;j++)
x09x09x09{
x09x09x09x09if(ans1==ans)
x09x09x09x09{
x09x09x09x09x09score+=10;
x09x09x09x09x09printf("Good!n");
x09x09x09x09x09break;
x09x09x09x09}
x09x09x09x09else
x09x09x09x09{
x09x09x09x09x09printf("Wrong,Try Again!n");
x09x09x09x09x09scanf("%d",&ans1);
x09x09x09x09}
x09x09x09}
x09x09x09break;
x09x09case 3:
x09x09x09ans2=(float)a/b;
x09x09x09printf("%d/%d=?n",a,b);
x09x09x09scanf("%d",&ans1);
x09x09x09for(j=0;j<2;j++)
x09x09x09{
x09x09x09x09if(ans1==ans2)
x09x09x09x09{
x09x09x09x09x09score+=10;
x09x09x09x09x09printf("Good!n");
x09x09x09x09x09break;
x09x09x09x09}
x09x09x09x09else
x09x09x09x09{
x09x09x09x09x09printf("Wrong,Try Again!n");
x09x09x09x09x09scanf("%d",&ans1);
x09x09x09x09}
x09x09x09}
x09x09x09break;
x09x09}
x09}
x09printf("您的成绩是:%dn",score);
x09return 0;
}
运行结果: