Advertisement
newb_ie

Untitled

Oct 28th, 2021
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include "bits/stdc++.h"
  2. using namespace std;
  3.  
  4. int main () {
  5. ios::sync_with_stdio(false);
  6. cin.tie(nullptr);
  7. cout.tie(nullptr);
  8. int x, y;
  9. char type;
  10. cin >> x >> y >> type;
  11. switch(type) {
  12. case '+':
  13. cout << x + y << '\n';
  14. break;
  15. case '-':
  16. cout << x - y << '\n';
  17. break;
  18. case '*':
  19. cout << x * y << '\n';
  20. break;
  21. case '/':
  22. if (y == 0) {
  23. cout << "cannot divide by zero\n";
  24. } else {
  25. cout << x / y << '\n';
  26. }
  27. break;
  28. case '%':
  29. cout << x % y << '\n';
  30. break;
  31. }
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement