提交时间:2023-10-31 18:47:05
运行 ID: 29551
#include<iostream> #include<iomanip> using namespace std; int main() { int a,b,x; char c; cin>>a>>b>>c; if(c=='+') { x=a+b; } else if(c=='-') { x=a-b; } else if(c=='*') { x=a*b; } else if(c=='/') { if(b==0) { cout<<"Divided by zero!"; return 1; } else { x=a/b; } } else { cout<<"Invalid operator!"; return 2; } cout<<x; return 0; }