/*有什么问题请给我留言我只写了下加法那部分,其他都基本差不多,颜色不会加!建议你多自己动手做题*/
#include
#include
#include
void plus();
void subtract();
void multiplication();
void division();
void remainder();
void main()
{
char a;
while(1)
{
printf("\n1->********A+B*********\n2->********A-B*********\n3->********A*B*********\n4->********A/B*********\n5->********A%%B*********\n6->********quit*********\n");
printf("choose:");
fflush(stdin);
a=getche();
printf("\n");
switch(a)
{
case '1':
plus();
break;
case '2':
subtract();
break;
case '3':
multiplication();
break;
case '4':
division();
break;
case '5':
remainder();
break;
case '6':
exit(1);
default:
printf("输入错误!请重新选择:\n");
continue;
}
}
}
void plus()
{
int a,b,c,d;
int i=3,seed;
seed=time(NULL);
srand(seed);
a=rand()%100+1;
b=rand()%100+1;
c=a+b;
end:
printf("%d+%d=",a,b);
scanf("%d",&d);
fflush(stdin);
if(d==c)
printf("You are right!");
else
{
if(i==1)
goto end1;
i--;
printf("You are wrong!\n");
goto end;
}
end1:
if(i==1)
{
printf("You already mistakenly three times!\n");
printf("Right answer is:%d+%d=%d\n",a,b,c);
}
}
void subtract()
{
}
void multiplication()
{
}
void division()
{
}
void remainder()
{
}