diff --git a/infix_to_postfix.cpp b/infix_to_postfix.cpp index 296420b..e1660e9 100644 --- a/infix_to_postfix.cpp +++ b/infix_to_postfix.cpp @@ -71,4 +71,83 @@ int main() infix_to_postfix(exp); return 0; -} \ No newline at end of file +} + +//using stack.h +#include +using namespace std; +#include "stack.h" + +int precedence(char s) +{ + if(s == '^') + return 1; + else if(s == '*' || s == '/') + return 2; + else if(s == '+' || s == '-') + return 3; + else if(s == '(' || s == ')') + return 4; + else + return -1; +} + +void infix_postfix(string exp) +{ + Stack s; + s.push('N'); + int l = exp.length(); + for(int i=0; i= 'a' && exp[i] <= 'z') || (exp[i] >= 'A' && exp[i] <= 'Z')) + cout<>exp; + + cout<<"Postfix expression: "; + infix_postfix(exp); + + return 0; +}