int main() {
int a, b, result;
char op;
scanf("%d%c%d",&a,&op,&b);
switch (op) {
case '+':result = a + b; break;
case '-':result = a - b; break;
case '*':result = a * b; break;
case '/':if (b != 0)
result = a / b;
break;
default:result = 0;
}
printf("%d %c %d =%d\n", a, op, b, result);
return 0;
}
四则运算 C语言
最新推荐文章于 2022-05-05 19:12:56 发布