2 solutions
-
0
Guest MOD
-
1
#include <bits/stdc++.h> using namespace std; int main() { int a,b;char c; cin >> a >> b >> c; if(c == '+') { cout << a + b; } if(c == '-') { cout << a - b; } if(c == '*') { cout << a * b; } if(c == '/') { if(b == 0) { cout << "Divided by zero!"; } else { cout << a / b; } } if(c != '+' && c != '-' && c != '*' && c != '/') { cout << "Invalid operator!"; } return 0; }
-
0
#include<iostream> using namespace std; int main(){ int a,b; char s; cin>>a>>b>>s; if(s=='/'&&b==0){ cout<<"Divided by zero!"; return 0; } if(s=='*'){ cout<<a*b; } else if(s=='+'){ cout<<a+b; } else if(s=='/'){ cout<<a/b; } else if(s=='-'){ cout<<a-b; } else{ cout<<"Invalid operator!"; } return 0; }
- 1
Information
- ID
- 675
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 7
- Tags
- (None)
- # Submissions
- 129
- Accepted
- 32
- Uploaded By