#include<stdio.h>
#include<stdlib.h>

typedef struct treeNode *ptr;
typedef treeNode tree;

typedef struct stackNode *ptrStack;
typedef ptrStack stack;

struct treeNode


{
char element;
ptr left;
ptr right;
};
struct stackNode


{
tree element;
ptrStack next;
};

tree polishToTree(char exp[])


{
int i=0;
stack s=creatStack();
while(exp[i]!='\0')

{
if(exp[i]!='+'&&exp[i]!='-'&&exp[i]!='*'&&exp[i]!='/')

{
tree tmpTree=creatTree();
tmpTree->element=exp[i];
tmpTree->left=tmpTree->right=NULL;
push(tmpTree,s);
}
else

{
tree tmpTree=creatTree();
tmpTree->element=exp[i];
tmpTree->right=top(s);
pop(s);
tmpTree->left=top(s);
pop(s);
push(tmpTree,s);
}
i++;
}
tree result=top(s)->element;
pop(s);
return result;
}
