c语言switch case语句中调用函数 求改错 十万火急 50

#include"stdio.h"#include"time.h"#include"stdlib.h"intaddition(inta,intb,inti);intsub... #include"stdio.h"
#include"time.h"
#include"stdlib.h"
int addition(int a,int b,int i);
int subduction(int a,int b,int i);
int multiplication(int a,int b,int i);
int division(int a,int b,int i);
int select(int n)
{
int i;
printf("input 0 test addition\n");
printf("input 1 test subduction\n");
printf("input 2 test multiplication\n");
printf("input 3 test division\n");
printf("please input 0 or 1 or 2 or 3:\n");
scanf("%d",&n);
srand( (unsigned)time( NULL ) );
printf("test begin:");
for(i=0;i<5;i++)
{
switch(n)
{
case 0:
{addition(int a,int b,int i);break;}
case 1:
subduction(int a,int b,int i);break;
case 2:
multiplication(int a,int b,int i);break;
case 3:
division(int a,int b,int i);break;
}
}
}
int addition(int a,int b,int i)
{
int snm=0;
a=rand()%100;b=rand()%100;
printf("the %d question:%d+%d=\n",i,a,b);
scanf("%d",&m);
if(m==a+b){printf("Get it Right\n");sum+=10;}
else printf("Your answer is wrong,,right anwser is:%d\n",a+b);break;

}
int subduction(int a,int b,int i)
{
int snm=0;
a=rand()%100;b=rand()%100;
printf("the %d question:%d-%d=\n",i,a,b);
scanf("%d",&m);
if(m==a-b){printf("Get it Right\n");sum+=10;}
else printf("Your answer is wrong,,right anwser is:%d\n",a+b);break;

}
int multiplication(int a,int b,int i)
{
int snm=0;
a=rand()%100;b=rand()%100;
printf("the %d question:%d*%d=\n",i,a,b);
scanf("%d",&m);
if(m==a*b){printf("Get it Right\n");sum+=10;}
else printf("Your answer is wrong,,right anwser is:%d\n",a+b);break;

}
int division(int a,int b,int i)
{
int c,snm=0;
a=rand()%9+1;b=rand()%9+1;
c=a*b;
printf("the %d question:%d/%d=\n",i,c,b);
scanf("%d",&m);
if(m==c/b){printf("Get it Right\n");sum+=10;}
else printf("Your answer is wrong,,right anwser is:%d\n",a+b);break;

}

int main()
{int n;
printf("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
printf("\n");
printf(" arithmetic test");
printf("\n");
printf("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
select(n);

}
展开
 我来答
碧血玉叶花
推荐于2018-04-08 · TA获得超过4976个赞
知道大有可为答主
回答量:6154
采纳率:0%
帮助的人:1726万
展开全部
# include <stdio.h>
void main()

{
int I, k, a, b, c, d, e, f,g;
printf("请输入利润I:\n");
scanf("%d", &I);
a = I * (1.0f/10);               //此处强制为浮点类型,不然a一直是0,看你的意思了
b = (I - 100000) * 75/1000;
c = (I - 200000) * 5/100;
d = (I - 400000) * 3/100;
e = (I - 600000) * 15/1000;
f = (I - 1000000) * 1/100;

g = (I - 1) / 100000;

switch(g)
{
       case 0:
            printf("奖金总数k=%d\n", a);
            break;
       case 1:       
              printf("奖金总数k=%d\n", a + b);
              break;
       case 2:
       case 3:
               printf("奖金总数k=%d\n", a + b + c);
               break;
       case 4:
       case 5:
               printf("奖金总数k=%d\n", a + b + c + d);
               break;
      case 6:
      case 7:
      case 8:
      case 9:
                printf("奖金总数k=%d\n", a + b + c + d + e);
                break;
      default :
                printf("奖金总数k=%d\n", a + b + c + d + e + f);
                break;
}
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

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

类别

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

说明

0/200

提交
取消

辅 助

模 式