已经解决了谢谢各位
#include <stdio.h>#include <stdlib.h>
#include <time.h>
void main()
{int a,b,c,op,answer,number,i,t;
char again='y';
while(again='y'||again=='Y')
{
printf("*****************************************************************\n\n");
printf(" 欢迎来到算术习题系统! \n\n");
printf("\t\t1.加法算数\n");
printf("\t\t2.减法算数\n");
printf("\t\t3.退出\n\n");
printf("*****************************************************************\n\n");
printf("请输入你的选择(1,2or3):");
scanf("%d",&op);
switch(op)
{case 1:
number=0;
for(i=1;i<=3;i++)
{srand(time(0));
a=rand()%10;
b=rand()%10;
printf("%2d+%2d=",a,b);
c=a+b;
scanf("%d",&answer);
if(c==answer)
{printf("\t 正确\n");
number++;
}
else
printf("\t 错误\n");
}
printf("你答对了:%d题\n",number);
break;
case 2:
number=0;
for(i=1;i<=3;i++)
{
srand(time(0));
a=rand()%10;
b=rand()%10;
if(a<b)
{t=a;a=b;b=t;}
printf("%2d-%2d=",a,b);
c=a-b;
scanf("%d",&answer);
if(c==answer)
{ printf("\t 正确\n");
number++;
}
else
printf("\t 错误\n");
}
printf("你答对了:%d题\n",number);
break;
case 3:printf("再见!\n");exit(0);break;
}
fflush(stdin);
printf("要再做多一次吗?(Y/N):");
scanf("%c",&again);
system("cls");
}
}
[此贴子已经被作者于2016-4-13 17:55编辑过]