Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Count {
- public:
- int k = 0;
- int r = 0;
- void oper1(int a, char ch, int b);
- void oper2(char s, int b);
- int print();
- };
- void Count::oper1(int a, char s, int b) {
- switch (s) {
- case '+':
- r = a + b;
- break;
- case '-':
- r = a - b;
- break;
- case '*':
- r = a * b;
- break;
- case '%':
- r = a % b;
- break;
- }
- k++;
- }
- void Count::oper2(char s, int b) {
- switch (s) {
- case '+':
- r = r + b;
- break;
- case '-':
- r = r - b;
- break;
- case '*':
- r = r * b;
- break;
- case '%':
- r = r % b;
- break;
- }
- k++;
- }
- int Count::print() {
- return r;
- }
- int main() {
- int a, b;
- char s;
- Count count = Count();
- cin >> a >> s >> b;
- count.oper1(a, s, b);
- cin >> s;
- while(s != 'C') {
- cin >> b;
- count.oper2(s, b);
- if(count.k % 3 == 0)
- cout << count.print() << endl;
- cin >> s;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement