Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|
24290 | 老方 | 简单计算器 | C++ | Accepted | 0 MS | 252 KB | 583 | 2023-08-10 12:56:54 |
#include<iostream> using namespace std; int main(){ int a,b; char s; cin>>a>>b>>s; switch (s) { case '+': cout<<a+b; break; case '-': cout<<a-b; break; case '*': cout<<a*b; break; case '/': if(b=0){ cout<<"Divided by zero!"; break; } else cout<<a/b; break; default: cout<<"Invalid operator!"; } return 0; }