Hi, I'm trying to write a program that will take an infix notation postifx RPN. My problem is that I can't get it to print out the new equation if someone could try and help me out with that, Iit would be greatly appreciated.
#include <iostream>
#include <queue>
#include <stack>
using namespace std;
int main(){
stack<char> it;
queue<char> hold;
string input;
cout << "Please enter an equation" << endl;
cin >> input;
for(int i = 0; i < input.length(); i++){
char value = input.at(i);
while(it.empty() == true){
if(value >= 'A')
hold.push(value);
else{
if(value == '(')
it.push(value);
else if(value == ')')
while(it.top()!= '('){
hold.push(it.top());
it.pop();
}
else if(it.empty() == true || value == '*' ||value == '/' && !(it.top() == '*' || it.top() == '/'))
it.push(value);
else{
while(it.empty() == false && value == '+' || value == '-' || (value == '*' || value == '/') && (it.top() == '*' || it.top() =='/' )){
hold.push(it.top());
it.pop();
}
it.push(value);
}
}
}
}
while(it.empty() !=false)
{
hold.push(it.top());
it.pop();
}
while(hold.empty() == false)
{
hold.pop();
cout << hold.front() << endl;
}
cout << hold.front()<< endl;
}