// editor2
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#define MAX 100
typedef struct{
    char data[MAX];
    int top;
}stack;
void init(stack*s){s->top=-1;}
int isEmpty(stack*s){return s->top==-1;}
void push(stack*s,char c){s->data[++s->top]=c;}
char pop(stack*s){return s->data[s->top--];}
char peek(stack*s){return s->data[s->top];}
int prec(char c){
    if(c=='*'||c=='/')return 2;
    if(c=='+'||c=='-')return 1;
    return 0;
}
void infixtopostfix(char*infix){
    stack s;init(&s);
    int len=strlen(infix);
    for(int i=0;i<len;i++){
        if(isalnum(infix[i])) printf("%c",infix[i]);
        else if(infix[i]=='(')push(&s,infix[i]);
        else if(infix[i]==')'){
            while(peek(&s)!='(')printf("%c",pop(&s));
            pop(&s);
        } else{
            while(!isEmpty(&s)&&peek(&s)!='('&&prec(infix[i]<=prec(peek(&s)))
            printf("%c",pop(&s));
            push(&s,infix[i]);
        }
    }
    while(!isEmpty(&s))print("%c",pop(&s));
}
int main(){
    char infix[MAX];
    printf("enter infi expression:");
    scanf("%s",infix);
    printf("postfix:");
    infixtopostfix(infix);
    printf("\n");
    return 0;
}