```c
#include <stdio.h>
int main() {
int num1, num2, result;
char operator;
printf("请输入一个两位数的计算式(例如:12+34):");
scanf("%d%c%d", &num1, &operator, &num2);
switch (operator) {
case '+':
result = num1 + num2;
break;
case '-':
result = num1 - num2;
break;
case '*':
result = num1 * num2;
break;
case '/':
if (num2 == 0) {
printf("除数不能为0!
");
return 1;
}
result = num1 / num2;
break;
default:
printf("无效的运算符!
");
return 1;
}
printf("结果是:%d %c %d = %d
", num1, operator, num2, result);
return 0;
}
```
#include <stdio.h>
int main() {
int num1, num2, result;
char operator;
printf("请输入一个两位数的计算式(例如:12+34):");
scanf("%d%c%d", &num1, &operator, &num2);
switch (operator) {
case '+':
result = num1 + num2;
break;
case '-':
result = num1 - num2;
break;
case '*':
result = num1 * num2;
break;
case '/':
if (num2 == 0) {
printf("除数不能为0!
");
return 1;
}
result = num1 / num2;
break;
default:
printf("无效的运算符!
");
return 1;
}
printf("结果是:%d %c %d = %d
", num1, operator, num2, result);
return 0;
}
```
上一篇:让子弹飞的影评