Cod sursa(job #3313841)

Utilizator popescu_georgePopescu George popescu_george Data 7 octombrie 2025 09:24:21
Problema Evaluarea unei expresii Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.52 kb
#include<fstream>
using namespace std;
ifstream cin("evaluare.in");
ofstream cout("evaluare.out");
char c;
int A(int l)
{
    int r;
    if(!l)
        for(r=A(1);c=='+'||c=='-';c=='+'?cin.get(c),r+=A(1):(cin.get(c),r-=A(1)));
    else if(l==1)
        for(r=A(2);c=='*'||c=='/';c=='*'?cin.get(c),r*=A(2):(cin.get(c),r/=A(2)));
    else if(c=='(')
        cin.get(c),r=A(0),cin.get(c);
    else
        for(r=0;c>47&&c<58;r=r*10+c-48,cin.get(c));
    return r;
}
int main()
{
    return cin.get(c),cout<<A(0),0;
}