小学生四则运算
#include<stdio.h>#include<stdlib.h>
#include<math.h>
void menu()
{printf("*****欢迎进入小学生四则运算*****/n");
printf("1.加法/n");
printf("2.减法/n");
printf("3.乘法/n");
printf("4.除法/n");
printf("5.退出/n");
printf("按'Q'退出并重新选择运算方式");
}
void plu()
{int a,b,sum,c,flag=1,key;
do
{srand((unsigned)time(NULL));
a=random(90)+10;
b=random(90)+10;
sum=a+b;
printf("\n%d+%d="a,b);
do
{scanf("%d",&c);
if(sum==c)
{printf("回答正确,请继续\n");break;}
else printf("回答错误,请重新回答\n")
}while(1);
fflush(stdin);
printf("按任意键继续按'Q'返回重新选择运算方式");
if((key=getchar()=='Q'))
flag=0;
}while(flag);
}
void sub()
{int a,b,sum,c,flag=1,key;
do
{srand((unsigned)time(NULL));
a=random(90)+10;
b=random(90)+10;
sum=a-b;
printf("\n%d-%d="a,b);
do
{scanf("%d",&c);
if(sum==c)
{printf("回答正确,请继续\n");break;}
else printf("回答错误,请重新回答\n")
}while(1);
fflush(stdin);
printf("按任意键继续按'Q'返回重新选择运算方式");
if((key=getchar()=='Q'))
flag=0;
}while(flag);
}
void mul()
{int a,b,sum,c,flag=1,key;
do
{srand((unsigned)time(NULL));
a=random(90)+10;
b=random(90)+10;
sum=a*b;
printf("\n%d*%d="a,b);
do
{scanf("%d",&c);
if(sum==c)
{printf("回答正确,请继续\n");break;}
else printf("回答错误,请重新回答\n")
}while(1);
fflush(stdin);
printf("按任意键继续按'Q'返回重新选择运算方式");
if((key=getchar()=='Q'))
flag=0;
}while(flag);
}
void divi()
{int a,b,sum,c,flag=1,key;
do
{srand((unsigned)time(NULL));
a=random(90)+10;
b=random(90)+10;
while(a%b!=0)
{a=random(90)+10;
b=random(90)+10;};
sum=a/b;
printf("\n%d/%d="a,b);
do
{scanf("%d",&c);
if(sum==c)
{printf("回答正确,请继续\n");break;}
else printf("回答错误,请重新回答\n")
}while(1);
fflush(stdin);
printf("按任意键继续按'Q'返回重新选择运算方式");
if((key=getchar()=='Q'))
flag=0;
}while(flag);
}
main()
{int key;
do
{menu();
scanf("%d",&key);
switch(key);
{case1:plu();
break;
case2:sub();
break;
case3:mul();
break;
case4:divi();
break;
}
}while(key!=5);
}
这段代码报错不知道怎么修改 望大神解答急急急急!!!!!!!!!