单选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