Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "bits/stdc++.h"
- using namespace std;
- int main () {
- ios::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- int x, y;
- char type;
- cin >> x >> y >> type;
- switch(type) {
- case '+':
- cout << x + y << '\n';
- break;
- case '-':
- cout << x - y << '\n';
- break;
- case '*':
- cout << x * y << '\n';
- break;
- case '/':
- if (y == 0) {
- cout << "cannot divide by zero\n";
- } else {
- cout << x / y << '\n';
- }
- break;
- case '%':
- cout << x % y << '\n';
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement