Cod sursa(job #2251125)
| Utilizator | Data | 1 octombrie 2018 10:01:08 | |
|---|---|---|---|
| Problema | Evaluarea unei expresii | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.4 kb |
#include<bits/stdc++.h>
std::ifstream f("evaluare.in");std::ofstream g("evaluare.out");char *c;int F(int x){int R;char o;if(x==0){R=F(1);for(o=*c;o=='+'||o=='-';o=*c)c++,R=o=='+'?R+F(1):R-F(1);}else if(x==1){R=F(2);for(o=*c;o=='*'||o=='/';o=*c)c++,R=o=='*'?R*F(2):R/F(2);}else if(*c=='('){c++;R=F(0);c++;}else for(R=0;isdigit(*c);c++)R=10*R+*c-'0';return R;}int main(){c=new char[100010];f>>c;g<<F(0);return 0;}
