fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int sum(int a, int b)
  5. {
  6. int c=a+b;
  7. return c;
  8. }
  9.  
  10. int sub(int a, int b)
  11. {
  12. int c=a-b;
  13. return c;
  14. }
  15. float mult(int a, int b)
  16. {
  17. int c=a*b;
  18. return c;
  19. }
  20. float div(int a, int b)
  21. {
  22. int c=a/b;
  23. return c;
  24. }
  25.  
  26. int main ()
  27. {
  28. int x,y,q;
  29. char zn;
  30. cin >> x >> zn >> y;
  31. switch(zn)
  32. {
  33. case '+' :
  34. q = sum( x, y );
  35. break;
  36. case '-' :
  37. q = sub( x, y );
  38. break;
  39. case '*' :
  40. q = mult( x, y );
  41. break;
  42. case '/' :
  43. q = div( x, y );
  44. break;
  45. }
  46. cout << q;
  47. }
Success #stdin #stdout 0s 3344KB
stdin
3+24
stdout
27