\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
#include
#include
#include
#include
int comp(int);
int init(void);
int main(int argc, char* argv[])
{
int in;
do
{
init();
scanf("%d",&in);
assert(in>=0&&in<=4);
system("cls");
if (in!=0) comp(in);
}
while (in!=0);
return 0;
}
int init(void)
{
system("cls");
printf("1. Addition\n2. Subtraction\n3. Multiplication\n4. Division\n0. EXIT\n");
return 0;
}
int comp(int op)
{
int a,b,c;
float cfd;
printf("Input \'-1\' to exit!\n\n");
srand(time(NULL));
cfd=(float)(a/b);
do
{
a=rand()%100+1;
b=rand()%100+1;
switch(op){
case 1:printf("%d+%d=",a,b);
b=a+b;
break;
case 2:while (a-b<0) {
a=rand()%100+1;
b=rand()%100+1;
}
printf("%d-%d=",a,b);
b=a-b;
break;
case 3:printf("%d*%d=",a,b);
b=a*b;
break;
case 4:while (aa=rand()%100+1;
b=rand()%100+1;
cfd=a/b;
}
printf("%d/%d=",a,b);
b=a/b;
break;
}
scanf("%d",&c);
b==c?printf("\nRight!\n"):printf("\nWrong! It's %d\n",b);
}while (c!=-1);
return 0;
}
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\