Advertisement
Guest User

Untitled

a guest
Apr 10th, 2020
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. int c = 0;
  7.  
  8. class mat
  9. {
  10.     public:
  11.     char ch;
  12.     int a, b;
  13.     void oper (int a, char ch, int b)
  14.     {
  15.         switch (ch)
  16.         {
  17.             case '+':
  18.                 c = a + b;
  19.                 break;
  20.             case '-':
  21.                 c = a - b;
  22.                 break;
  23.             case '*':
  24.                 c = a * b;
  25.                 break;
  26.             case '%':
  27.                 c = a % b;
  28.                 break;
  29.         }
  30.     }
  31. };
  32.  
  33. int main()
  34. {
  35.     mat z;
  36.     int a, b;
  37.     char ch;
  38.     cin >> a >> ch >> b;
  39.     z.oper(a, ch, b);
  40.     cout << c;
  41.     int t = 0;
  42.     while (ch != 'C')
  43.     {
  44.         t++;
  45.         cin >> ch >> b;
  46.         if (ch == 'C')
  47.             break;
  48.         else
  49.         {
  50.             z.oper (c, ch, b);
  51.             if (t%3 == 0)
  52.                 cout << endl << c ;
  53.         }
  54.     }
  55.    
  56.     return(0);
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement