Cod sursa(job #1812516)

Utilizator sabinantonSabin Anton sabinanton Data 22 noiembrie 2016 10:24:36
Problema Bool Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.77 kb
#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;
}