blob: 0b7ef87f40672c01de325e86f41a41de9cd2d701 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#include <iostream>
int main() {
int current = 0, memory = 0, temp = 0;
std::cin >> current;
char buff;
bool printMem = false;
while (true) {
std::cin >> buff;
switch (buff) {
case 'a': memory += current; printMem = true; break;
case 's': memory -= current; printMem = true; break;
case 'm': memory = 0; printMem = true; break;
case 'c': current = 0; std::cout << current << std::endl; continue;
}
if (printMem) {
std::cout << memory << std::endl;
printMem = false;
continue;
}
std::cin >> temp;
switch (buff) {
case '+': current += temp; break;
case '-': current -= temp; break;
case '*': current *= temp; break;
case '/': current /= temp; break;
}
std::cout << current << std::endl;
}
}
|