360c语言源代码,C语言源代码

满意答案

02ae427d08e371d7e90d5b995e828d6d.png

wy123lhb

2013.11.27

02ae427d08e371d7e90d5b995e828d6d.png

采纳率:53%    等级:12

已帮助:8280人

大体上可以满足你的要求了,个别细节你再自己看看吧,我困的实在不行了。。

DEV C++ 编译通过,运行正常 。

#include

#include

#include

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

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",&times);

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;

}

00分享举报

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值