C语言第四章作业

C语言第四章作业,第1张

C语言第四章作业

单选5

#include
#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
int main()
{
    int x, y;
    switch ()
    {
        case x >= 0:y = 1;
        break;
        default:y = -1;
    }
    return 0;
}

 

 阅读程序题2

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

 

 编程题3#include
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
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

 

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5521487.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-12-13
下一篇2022-12-13

发表评论

登录后才能评论

评论列表(0条)

    保存