选择题5
#includeint main() #define N 8 { int x = 2, z = 1; double y = 1.2; switch (x) { case 2: y++; break; case '0': y = 3; } printf("%.2fn", y); }
选择题9
#includeint main() { int x, y; printf("整数:"); scanf_s("%d", &x); switch (x-abs(x)) { case 0:y = 1; break; default :y = -1; } printf("%d", y); return 0; }
阅读2
#includeint main() { int i = 1, n = 0; switch (i) { case 1: case2:n++; case3: n++; } printf("%d", n); return 0; }
编程3
#includeint 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#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; }



