Pagini recente » Cod sursa (job #1650471) | Cod sursa (job #2175201) | Cod sursa (job #290182) | Cod sursa (job #726395) | Cod sursa (job #299934)
Cod sursa(job #299934)
#include<fstream.h>
char S[100001],*p=S;
long t();
long f();
long e();
int main()
{ifstream f("evaluare.in");
ofstream g("evaluare.out");
f.get(S,100001);
g<<e();
return 0;
}
long e()
{long x=t();
if(*p=='+')
{++p;
x=x+t();}
if(*p=='-')
{++p;
x=x-t();}
return x;
}
long t()
{long x=f();
if(*p=='*')
{++p;
x=x*f();}
if(*p=='/')
{++p;
x=x/f();
}
return x;
}
long f()
{long x=0;
if(*p=='(')
{++p;
x=e();
++p;}
else
while(*p>='0'&&*p<='9')
{x=x*10+*p-'0';
++p;}
return x;
}