C语言第四章作业

单选5

#include<stdio.h>
#define N8
int main()
{
 int x = 2, z = 1;
 double y = 1.2;
 switch(x)
 {
 case 2:y++;
  break;
 case '0':y = 3;
 }

 

 单选9

#include<stdio.h>
int main()
{
    int x, y;
    switch ()
    {
        case x >= 0:y = 1;
        break;
        default:y = -1;
    }
    return 0;
}

 

 阅读程序题2

#include<stdio.h>
int main()
{
 int i=1,n=0;
 switch(i)
 { case 1:
 case 2:n++;
 case 3:n++;
 }
 printf("%d", n);
 return 0;
}

 

 编程题3#include<stdio.h>
int main()
{
 int a, b;
 char c;
 scanf_s("%d %c %d", &a, &c,1, &b);
 switch (c) {
 case '+':
  printf("%d + %d = %d", a, b, (a + b));
  break;
 case '-':
  printf("%d - %d = %d", a, b, (a - b));
  break;
 case '*':
  printf("%d * %d = %d", a, b, (a * b));
  break;
 case '/':
  if (b == 0) {
   printf("b不可为0");
  }
  else {
   printf("%d / %d = %d", a, b, (a/b));
  }
  break;
 default:
  printf("运算符不在四则中");
  break;
 }
 return 0;

 

 编程题4

#include<stdio.h>
int main()
{
 float salary, sale;
 printf("输入销售额:");
 scanf_s("%f", &sale);
 if (sale < 10000)
  salary = 1000;
 else if (sale < 20000)
  salary = 1000 + (sale - 10000) * 0.05;
 else if (sale < 50000)
  salary = 1000 + 10000 * 0.05 + (sale - 20000) * 0.06;
 else if (sale < 100000)
  salary = 1000 + 10000 * 0.05 + 30000 * 0.06 + (sale - 50000) * 0.07;
 else
  salary = 1000 + 10000 * 0.05 + 30000 * 0.06 + 50000 * 0.07 + (sale - 100000) * 0.08;
 printf("工资=%.3f", salary);
 return 0;
}

 

文字描述:

销售额        基本工资        提成
1w以下        1000        0
1-2w        1000        (销售额-1w)*0.05
2-5w        1000        (销售额-2w)*0.06
5-10w        1000        (销售额-5w)*0.07
10w以上        1000        (销售额-10w)*0.08

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值