float a = 0, b = 0, c = 0; char count = 0; printf("输入运算\n"); scanf("%f%c%f",&a,&count,&b); switch (count) { case'+':{ c = a + b; } printf("结果为%.2f",c); break; case'-':{ c = a - b; } printf("结果为%.2f",c); case'*':{ c = a * b; } printf("结果为%.2f",c); break; case'/':{ if (b == 0) { printf("节操呢"); break; } c = a / b; } printf("结果为%.2f",c); break; default: break; }