Blame view

P20006_en/S001-AC.cc 463 Bytes
Imanol-Mikel Barba Sabariego authored
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
33
34
35
36
37
38
39
40
41
42
43
#include <iostream>

using namespace std;

int operate(char op)
{
	int a = 0,b;
	char c;
	for(int j = 0; j < 2; j++)
	{
		b = a;
		cin >> c;
		if(cin.eof())
		{
			return a;
		}
		if(c != '+' && c != '-' && c != '*')
		{
			a = c - 48;
		}
		else
		{
			a = operate(c);
		}
	}
	switch(op)
	{
		case '+':
			return b+a;
			break;
		case '-':
			return b-a;
			break;
		case '*':
			return b*a;
			break;
	}
}
int main()
{
	cout << operate(0) << endl;
	return 0;
}