#include <iostream> #include <bits/stdc++.h> using namespace std; int main() { double operand1 = 0, operand2 = 0; //定义操作数和运算法变量 char ope; cin >> operand1 >> ope >> operand2; //输入操作数和运算法 switch (ope) { case '+': cout << fixed << setprecision(4) << operand1 << "+" << operand2 << "=" << operand1 + operand2; break; case '-': cout << fixed << setprecision(4) << operand1 << "-" << operand2 << "=" << operand1 - operand2; break; case '*': cout << fixed << setprecision(4) << operand1 << "*" << operand2 << "=" << operand1* operand2; break; case '/': { if (operand2 == 0) { cout << "Wrong!Division by zero!"; } else { cout << fixed << setprecision(4) << operand1 << "/" << operand2 << "=" << operand1 / operand2; } } break; default: cout << "Invalid operation!"; break; } system("pause"); return 0; }