#include <stdio.h>
int main() {double a, b, d;//用来接收浮点数char c;//用来接受符号scanf("%lf %c %lf", &a, &c, &b);if (c == '+' || c == '-' || c == '*' || c == '/')//判断输入的运算符号不包括在(+、-、*、/)范围内{switch (c)//根据符号计算表达式的值{case '+':d = a + b;break;case '-':d = a - b;break;case '*':d = a * b;break;case '/':d = a / b;break;}if (c == '/' && b == 0.0)//除法分母为零的情况{printf("Wrong!Division by zero!");}else{ //正常情况printf("%.4lf%c%.4lf=%.4lf", a, c, b, d);//按题意要求输出四位小数}}else { //输入的运算符号不包括在(+、-、*、/)范围内printf("Invalid operation!");}return 0;
}