how to get out and print

I am writing a program that will print out a normal equation into Reverse polish notation....My problem is that now I am in a forever loop and can not print it.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <iomanip>
#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)
        {
                cout << hold.front() << endl;
                hold.pop();
        }
}

Last edited on
Topic archived. No new replies allowed.