提交时间:2024-01-23 16:18:23

运行 ID: 125007

#include <bits/stdc++.h> using namespace std; int main() { int a, b; char o; cin >> a >> o >> b; switch (o) { case '+': cout << a + b; break; case '-': cout << a - b; break; case '*': cout << a * b; break; case '/':{ switch (b){ case 0: cout<<"Divided by zero!"; return 0; } cout<<a / b; break; } default: cout << "Invalid operator!"; } return 0; }