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

运行 ID: 124885

#include<iostream> #include<cstdio> 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; }