1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-11-27 14:36:19 +00:00
202401-programming-assignments/【额外练习】选择结构/7-15 选择-简易计算机.c

52 lines
829 B
C
Raw Normal View History

2024-10-30 15:00:18 +00:00
#include <stdio.h>
int main() {
int x, a, b, c;
scanf("%d%d%d%d", &x, &a, &b, &c);
switch (x) {
case 0:
printf("%d", a + b);
break;
case 1:
printf("%d", a - b);
break;
case 2:
printf("%d", a * b);
break;
case 3:
printf("%d", a / b);
break;
case 4:
printf("%d", a % b);
break;
case 5:
printf("%d", a ? b : c);
break;
case 6:
printf("%d", a > b);
break;
case 7:
printf("%d", a < b);
break;
case 8:
printf("%d", a != b);
break;
case 9:
printf("%d", a == b);
break;
}
return 0;
}