#include //input &output #include //string function #include //getch function int main() { int i=0,top=-1,j=0;//tarife esharegar be araye char infix[20],stack[20],postfix[20]; char r='y'; while(r=='y') { for(int c=0;c<20;c++) { infix[c]='\0'; postfix[c]='\0'; stack[c]='\0'; i=0; j=0; top=-1; } cout<<"please type infix phrases :"; cin>>infix; while(infix[i]!='\0') { if(infix[i]=='(' || infix[i]=='+' || infix[i]=='-' || infix[i]=='/' || infix[i]=='*' || infix[i]=='^') stack[++top]=infix[i]; else if(infix[i]==')') { while(stack[top]!='(' && top>=0) { postfix[++j]=stack[top]; top--; } if(stack[top]=='(') top--; } else postfix[++j]=infix[i]; i++; } if(top>=0) for(int cc=top;cc>=0;cc--) postfix[++j]=stack[cc]; cout<<"postfix phrases of "<>r; cout<<"\n******************************************\n"; } getch(); }