问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

C语言源代码

发布网友 发布时间:2022-04-24 08:22

我来回答

1个回答

热心网友 时间:2022-04-26 14:13

大体上可以满足你的要求了,个别细节你再自己看看吧,我困的实在不行了。。
DEV C++ 编译通过,运行正常 。

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>

void practisesys(void);
void testsys(void);
int typechoose(void);
int Addition(int,int);
int Subtraction(int,int);
int Multiplication(int,int);
int Division(int,int);

int main(void)
{
int choose;
printf(" =====================================================================\n\n");
printf("\t\t Welcome to the math study system\n\n");
printf(" =====================================================================\n\n");
printf("\t\t[1].practise\t\t\t[2].test\n");
printf("\nPlease choose one option of the two:");
scanf("%d",&choose);
if(choose == 1)
{
practisesys();
system("cls");
}
else if(choose == 2)
{
testsys();
system("cls");
}
else
{
printf("Input a wrong number,exit...\n");
getch();
return 0;
}
system("PAUSE");
return 0;
}

void practisesys(void)
{
int n1,n2,result,type,input,right,wrong;
right = 0;
wrong = 0;
type = typechoose();
system("cls");
do
{
do
{
srand((unsigned)time(NULL));
n1 = rand()%100;
n2 = rand()%100;
}while(n1<n2);
label1:
if(type == 1)
{
result = Addition(n1,n2);
printf("%d + %d =",n1,n2);
}
else if(type == 2)
{
result = Subtraction(n1,n2);
printf("%d - %d =",n1,n2);
}
else if(type == 3)
{
result = Multiplication(n1,n2);
printf("%d * %d =",n1,n2);
}
else if(type == 4)
{
result = Division(n1,n2);
printf("%d / %d =",n1,n2);
}
else if(type == 5)
{
srand((unsigned)time(NULL));
type = rand()%4+1;
goto label1;
}
scanf("%d",&input);
if(input == result)
{
right++;
printf("you are right!\n");
}
else
{
wrong++;
printf("you are wrong!\n");
}
}while(1);
printf("you anwsered the question rightly for %d .\n",right);
printf("you totally anwsered the question for %d .\n",right+wrong);
printf("your answer's exactitude rateaccuracy rate is %d %%.\n",right/(right+wrong)*100);
printf("Welcome to use the program!\n");
getch();
return;
}
void testsys(void)
{
int n1,n2,result,input,i,right,wrong,times,sum;
right = 0;
wrong = 0;
sum = 0;
system("cls");
printf("please input how many times would you like to test:");
scanf("%d",×);
do
{
srand((unsigned)time(NULL));
n1 = rand() % 100;
n2 = rand() % 100;
i = rand() % 4+1;
if(i == 1)
{
result = Addition(n1,n2);
printf("%d + %d =",n1,n2);
}
else if(i == 2)
{
result = Subtraction(n1,n2);
printf("%d - %d =",n1,n2);
}
else if(i == 3)
{
result = Multiplication(n1,n2);
printf("%d * %d =",n1,n2);
}
else if(i == 4)
{
result = Division(n1,n2);
printf("%d / %d =",n1,n2);
}
scanf("%d",&input);
if(input == result)
{
right++;
printf("you are right!\n");
}
else
{
wrong++;
printf("you are wrong!\n");
}
}while(sum++ <= times);
printf("you anwsered the question rightly for %d .\n",right);
printf("you totally anwsered the question for %d .\n",right+wrong);
printf("your answer's exactitude rateaccuracy rate is %d %%.\n",right/(right+wrong)*100);
printf("you get the score of %d",right*10);
printf("Welcome to use the program!\n");
getch();
return;
}

int typechoose(void)
{
int choose,flag;
do
{
system("cls");
flag = 0;
printf("1.Addition arithmetic\n2.Subtraction arithmetic\n3.Multiplication arithmetic\n4.Division arithmetic\n5.Commixture arithmetic\n");
printf("\nplease input a number that you choose:");
scanf("%d",&choose);
if(choose != 1 && choose != 2 && choose != 3 && choose != 4 && choose != 5)
{
flag = 1;
}
}while(flag);
return choose;
}

int Addition(int n1,int n2)
{
return n1+n2;
}

int Subtraction(int n1,int n2)
{
return n1-n2;
}

int Multiplication(int n1,int n2)
{
return n1*n2;
}

int Division(int n1,int n2)
{
return n1/n2;
}
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
运航不锈钢304方管有哪几种型号 镀锌方管有哪些型号 方管型号有哪些 方管的型号有哪些 牌照过户要换新的吗 ...自己一辆江苏牌照的小汽车,名下还能拥有一辆杭州牌照的车吗?_百度... 方管有哪些厚度 国标方管的厚度有哪些规格? 学龄前,应该教会孩子哪些技能才合适? 对学龄前孩童来说什么最重要? 手长水泡又会痒用什么比较好啊!求大神帮助 C语言源代码学习方法 手长水泡的是怎么回事 C语言,C语言源代码到底是什么意思 手长了小水泡,很痒,可能之前抓破了又去摸其他地方,膝盖都有了,搽什么药? 手长水泡,痒怎么办 c语言入门学习 源代码如何编写 关于手长小水泡的问题 c语言程序源代网站 手长水泡泡了,是怎么回事? 被评估人对2015年工作完成情况进行总结怎么写 手长水泡是因为什么 夏天手长小水泡怎么办 手长水泡是怎么回事? 手长水泡怎么办? 手长泡泡,要怎么好 手长水泡很痒是什么原因 手长水泡怎么办 音叉液位物位开关在测量高温时水需要注意哪些问题? 音叉液位计的产品特点 谁有c语言源代码完整点的,学习用。 本人刚学习C语言,求标准格式的源代码。 单片机C语言程序设计实训100例基于8051的源代... C语言源代码分析(越易懂越好,我只是一个初学者) 求C语言标准函数库的源代码 家里装wifi一共需要多少钱? 家里安个无线网两年1000块钱贵不贵? 装个无线网一年要多少钱? 安一个无线网多少钱? 安无线网需要多少钱 目前安装无线网的话,大概需要多少钱呢? 家里安装wifi多少钱 有谁知道安装无线网需要多少钱 想装一个wifi,具体要花多少钱? 有关舞蹈的古诗词 为什么吃辣的东西脸会红 吃辣椒为什么会脸变红? 吃了辣椒以后脸上一片一片的红? 请问喝酒了不红脸,为什么一吃辣椒脸就会很红 一吃辣脸就起一片红?