C语言编程 设计一个100以内的整数四则运算测试程序

(1)Givetheoptionmenutointegratevariousfunctionmodule.选项菜单集成各功能函数模块(2)Setsthetopicofac... (1) Give the option menu to integrate variousfunction module.选项菜单集成各功能函数模块

(2) Sets the topic of a composition (each timesets 5 topics).出题(每次出10道题目)
(3) Answer and grade.答题并评分
(4) Give the correct answer to the wrong topic.答错的题给出正确答案
(5) Demonstrating the answer paper显示答卷
展开
 我来答
xoaxa
推荐于2016-11-21 · TA获得超过8607个赞
知道大有可为答主
回答量:6415
采纳率:72%
帮助的人:3388万
展开全部
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

const int MAXSIZE = 10;

int CheckResult(int anwser,int result) {
if(anwser == result) {
printf("对的,继续努力\n");
return 1;
}
printf("错了,正确答案是:%d\n",result);
return 0;
}

int main() {
int a,b,t,answer,result;
int n = MAXSIZE,yes = 0,no = 0;
char op,ops[] = {"+-*/"};
srand((unsigned)time(NULL));
while(n--) {
op = rand()%4;
switch(ops[op]) {
case '+' : do {
a = rand()%90 + 10;
b = rand()%90 + 10;
}while(a + b >= 100);
printf("%d + %d = ",a,b);
scanf("%d",&answer);
if(CheckResult(answer,a + b)) ++yes;
else ++no;
break;
case '-' : a = rand()%90 + 10;
b = rand()%90 + 10;
if(a < b) {t = a; a = b; b = t; }
printf("%d - %d = ",a,b);
scanf("%d",&answer);
if(CheckResult(answer,a - b)) ++yes;
else ++no;
break;
case '*' : do {
a = rand()%100;
b = rand()%100;
}while(a * b >= 100);
printf("%d * %d = ",a,b);
scanf("%d",&answer);
if(CheckResult(answer,a * b)) ++yes;
else ++no;
break;
case '/' : do {
a = rand()%90 + 1;
b = rand()%90 + 1;
}while(a % b && b % a);
if(a % b) {t = a; a = b; b = t; }
printf("%d / %d = ",a,b);
scanf("%d",&answer);
if(CheckResult(answer,a / b)) ++yes;
else ++no;
break;
}
}
printf("答对:%d个,答错:%d个,正确率:%.2lf%%\n",yes,no,100.0 * yes / MAXSIZE);
return 0;
}
追问
能不能备注一下具体步骤内容    每个点在什么地方
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式