Pagini recente » Cod sursa (job #2731939) | Cod sursa (job #2999571) | Cod sursa (job #2984123) | Cod sursa (job #1287082) | Cod sursa (job #2896861)
#include <bits/stdc++.h>
using namespace std;
int pos = 0;
string t;
int eval();
int half() {
int temp = 0;
if(t[pos]=='(') {
pos++;
temp = eval();
pos++;
}
else while(t[pos] >= '0' and t[pos] <= '9') temp = temp * 10 + (t[pos++] - '0');
return temp;
}
int eval() {
int temp = half();
while(t[pos]=='m' or t[pos]=='M')
t[pos++] == 'm' ? temp = min(temp, half()) : temp = max(temp, half());
return temp;
}
int main() {
ifstream f("emm.in");
ofstream g("emm.out");
f >> t;
g << eval();
return 0;
}