#include #include #include using namespace std; void chyba(char * s){ cout << "Vyraz " << s << " obsahuje chybu." << endl; system("PAUSE"); exit(1); } class vyraz { private: string obsah; int spocti(string co, int * n); public: vyraz(char * s); int vyhodnot(int * n); string vypis(); }; vyraz::vyraz(char *s){ obsah.clear(); bool promenna = false, operand = false, minus = false; int zavorky = 0; for(unsigned int i = 0; i '9') chyba(s); promenna = true; }else if(s[i] >= '0' && s[i] <= '9'){ operand = false; minus = false; if(promenna) chyba(s); }else { chyba(s); } obsah += s[i]; } } if(zavorky > 0) chyba(s); } int vyraz::spocti(string co, int * n){ string leva, prava; bool operand = false; unsigned int i=0, zavorek=0; while(co[0] == '(' && co[co.length() - 1] == ')'){ co.erase(co.begin()); co.erase(co.end()-1); } if(co.find('+',0) == string::npos && co.find('-',0) == string::npos && co.find('*',0) == string::npos && co.find('/',0) == string::npos) { if(co[0] != '$') { return atoi(co.c_str()); } else { co.erase(co.begin()); return n[atoi(co.c_str())]; } } while(i