Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool Operand(char x) {
- return (x >= 'a' && x <= 'z') || (x >= 'A' && x <= 'Z');
- }
- string GetInfix(string exp) //Evaluate to infix
- {
- StackOFQueue <string> s;
- for (int i = 0; exp[i] != '\0'; i++)
- {
- if (Operand(exp[i]))
- {
- string op(1, exp[i]);
- s.push(op);
- }
- else
- {
- string op1 = s.top();
- s.pop();
- string op2 = s.top();
- s.pop();
- s.push("(" + op2 + exp[i] +op1 + ")");
- }
- }
- return s.top();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement