Pagini recente » Cod sursa (job #1835419) | Cod sursa (job #83054) | Cod sursa (job #1584336) | Cod sursa (job #2429788) | Cod sursa (job #1812516)
#include <fstream>
#include <string.h>
//codeblocks the great!
using namespace std;
const int N = 100001;
ifstream in("emm.in");
ofstream out("emm.out");
char c[N];
int p=0;
int exp();
int ter();
int fact();
int exp()
{
int rez=fact();
while(c[p]=='m'||c[p]=='M')
{
if(c[p]=='M')
{
p++;
rez = max(rez, fact());
}
else
{
p++;
rez=min(rez,fact());
}
}
return rez;
}
int fact()
{
int semn=1,val=0;
if(c[p]=='(')
{
p++;
val=exp();
p++;
return val;
}
while(isdigit(c[p]))
{
val=val*10+(c[p]-'0');
p++;
}
return val;
}
int main()
{
in.getline(c,N);
out<<exp();
return 0;
}