啊哈磊_编程从这里起步
标题:
那位大神帮忙
[打印本页]
作者:
吆吆,切克闹
时间:
2020-12-23 00:45
标题:
那位大神帮忙
#include<stdio.h>
#include<stdlib.h>
void menu();
void add();
void sub();
void mul();
void div1();
void main()
{
int a; while(1)
{
menu();
printf("Please choose the option:"); scanf("%d",&a);
switch(a)
{
case 1: add(); break;
case 2: sub(); break;
case 3: mul(); break;
case 4: div1();break;
case 5: exit(0); break; default: break;
}
}
}
void menu()
{
printf("**************************************************");
printf("*@@@@@@ Xiao Xue Shu Xue Ce Shi Ruan Jian @@@@@@@*");
printf("**************************************************");
printf("*----------Please select your operation *");
printf("*------ 1. + jia fa ce shi *");
printf("*------ 2. - jian fa ce shi *");
printf("*------ 3. * chen fa ce shi *");
printf("*------ 4. / chu fa ce shi *");
printf("*------ 5. exit the system *");
printf("**************************************************");
}
void add()
{
int a,b,c,d,re=0,sum=0; system("cls");
while(1)
{
a=rand()%100; b=rand()%100; printf("%d+%d=",a,b);
scanf("%d",&c); if(c==(a+b))
{
re++; sum++;
printf("^_^Very good! You are right! Will you go on?The quantity of question is%dThe right is %d1. Go on 2. Exit",re,sum);
}
else
{
re++;
printf("Sorry!You are wrong! The right answer is %d.Will you go on?The quantity of question is %dThe right is %d1. Go on 2. Exit",a+b,re,sum);
}
scanf("%d",&d); if(d==2)
break; else system("cls");
}
system("cls");
}
void sub()
{
int a,b,c,d,re=0,sum=0; system("cls");
while(1)
{
a=rand()%100; b=rand()%100;
while((a-b)<0)
{
a=rand()%100; b=rand()%100;
}
printf("%d-%d=",a,b);
scanf("%d",&c);
if(c==(a-b))
{
re++; sum++;
printf("^_^Very good! You are right! Will you go on?The quantity of question is%dThe right is %d 1. Go on 2. Exit",re,sum);
}
else
{
re++;
printf("Sorry!You are wrong! The right answer is %d.Will you go on?The quantity of question is %dThe right is %d 1. Go on 2.Exit",a-b,re,sum);
}
scanf("%d",&d);
if(d==2)
break; else system("cls");
}
system("cls");
}
void mul()
{
int a,b,c,d,re=0,sum=0; system("cls");
while(1)
{
a=rand()%20; b=rand()%20; printf("%d*%d=",a,b);
scanf("%d",&c); if(c==(a*b))
{
re++; sum++;
printf("^_^ Very good! You are right! Will you go on?The quantity of question is%dThe right is %d1.Go on 2.Exit" ,re,sum);
}
else
{
re++;
printf("Soory! You are wrong! The right answer is %d.Will you go on? The quantity of question is %dThe right is %d1.Go on 2.Exit ",a*b,re,sum);
}
scanf("%d",&d); if(d==2)
break; else
system("cls");
}
system("cls");
}
void div1()
{
int a,b,c,d,sum=0,re=0; system("cls");
while(1)
{
a=rand()%100; b=rand()%100; if(b==0)
b=rand()%100; while((a%b)!=0)
{
a=rand()%100; b=rand()%100; if(b==0)
b=rand()%100;
}
printf("%d/%d=",a,b);
scanf("%d",&c); if(c==(a/b))
{
sum++;
re++;
printf("^_^ Very good! You are right! Will you go on?The quantity of question is%dThe right is %d1.Go on 2.Exit" ,re,sum);
}
else
{
re++;
printf("Soory! You are wrong! The right answer is %d.Will you go on? The quantity of question is %dThe right is %d1.Go on 2.Exit" ,a/b,re,sum);
}
scanf("%d",&d); if(d==2)
break; else system("cls");
}
system("cls");
}
复制代码
欢迎光临 啊哈磊_编程从这里起步 (https://bbs.codeaha.com/)
Powered by Discuz! X3.2