Cod sursa(job #2285690)

Utilizator HedeaMihneAHedea Mihnea HedeaMihneA Data 18 noiembrie 2018 22:27:05
Problema BFS - Parcurgere in latime Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.88 kb
#include<bits/stdc++.h>

using namespace std;
ifstream fin("evaluare.in");
ofstream fout("evaluare.out");
int E(),T(),F(),N();
char c;
int main()
{
    fout<<E();
    return 0;
}
int E()
{
    fin>>c;
    int R=T();
    while(c=='+'||c=='-')
        if(c=='+')
        {
            fin>>c;
            R+=T();
        }
        else
        {
            fin>>c;
            R-=T();
        }
    return R;
}
int T()
{
    int R=F();
    while(c=='*'||c=='/')
        if(c=='*')
        {
            fin>>c;
            R*=F();
        }
        else
        {
            fin>>c;
            R/=F();
        }
    return R;
}
int F()
{
    if(isdigit(c))
    return N();
    int R=E();
    fin>>c;
    return R;
}
int N()
{
    int R=0;
    while(isdigit(c))
    {
        R=10*R+c-'0';
        if(!(fin>>c))c=0;;
    }
    return R;
}