Witam, chcę stworzyć sobie program generujący mnie z podanego wyrażenia wyrażenie zapisane w ONP, ten kod co mam nie działa dobrze, a nie mogę znaleźć błędu, liczę na pomoc, nie gotowca
std::vector<std::string> NOP(std::vector<std::string> w)
{
std::vector<std::string> wyjscie;
std::stack<std::string> stos;
std::map<std::string, short> ww;
ww["#"] = 0;
ww["+"] = 1;
ww["-"] = 1;
ww["*"] = 2;
ww["/"] = 2;
ww["%"] = 2;
ww["^"] = 3;
stos.push("#");
for (auto it = 0; it <w.size(); it++){
//element jest stałą
if (w[it]=="0" || atoi(w[it].c_str())!=0){
wyjscie.push_back(w[it]);
}
else{
//znak jest "("
if (w[it] == "(") {
stos.push(w[it]);
}
if (w[it]==")") {
stos.pop();
while (stos.top()!="(")
{
wyjscie.push_back(stos.top());
}
stos.pop();
while (stos.top()!="#")
{
if (stos.top()=="("){
stos.pop();
break;
}
else {
wyjscie.push_back(stos.top());
stos.pop();
}
}
}
if (w[it] == "+" || w[it] == "-" || w[it] == "*" || w[it] == "/" || w[it] == "%" || w[it] == "^") {
//wczytywany jest wiekszy
if (ww[w[it]]>ww[stos.top()]) {
stos.push(w[it]);
}
if (ww[w[it]] <= ww[stos.top()]) {
while (stos.top()!="#" || ww[w[it]]<ww[stos.top()])
{
wyjscie.push_back(stos.top());
stos.pop();
}
}
}
}//stos.empty() != true
while (stos.top() != "#") {
wyjscie.push_back(stos.top());
stos.pop();
}
return wyjscie;
}