求幫忙看一下為什麼這個代碼計算不了,而且輸入b=0的還是0.00,不能輸出Unknown operator
#include <stdio.h>
int main(void) {
float a,b;
char ch;
scanf("%f%c%f", &a, &ch, &b);
switch (ch)
{
case '+': printf("=%.2f", a + b); break;
case '-': printf("=%.2f", a - b); break;
case '*': printf("=%.2f", a * b); break;
case '/': printf("=%.2f", a / b); break;
default: printf("Unknown operator");
}
return 0;
}
http://ideone.com/4vMmvI
在線測試,沒問題