前缀表达式转后缀表达式

题目:前缀表达式和后缀表达式的文法分别为:前e->(e.e)|+(e.e)|a后e->(e.e)|(e.e)+|a编一个程序。输入一个前缀表达式,输出一个与之等价的后缀表达式:假设输入的前缀表达式没有语法错误。例如:输入+(*(a,+(a,a)),a)输出((a,(a,a)+)*,a)+

#include
#include
#include
#include
#define MaxSize 50
//前缀表达式和后缀表达式的文法分别为:前e->(e.e)|+(e.e)|a后e->(e.e)|(e.e)+|a编一个程序。输入一个前缀表达式,输出一个与之等价的后缀表达式:假设输入的前缀表达式没有语法错误。例如:输入+(*(a,+(a,a)),a)输出((a,(a,a)+)*,a)+
typedef char Elemtype;
struct Stack
{
Elemtype data[MaxSize];
int top;
};
int main()
{
struct Stack s;
void InitStack(struct Stack *s);
bool Pop (struct Stack *s,Elemtype *x);
bool Push (struct Stack *s,Elemtype x);
Elemtype x;
int i=0;
char str[MaxSize];
printf("请输入前缀表达式:");
scanf("%s",str);
printf("对应的后缀表达式:");
InitStack(s);
while(str[i]!='\0')
{
if(str[i]=='('||(str[i]>='a'&&str[i]<='z'))
{
printf("%c",str[i]);
continue;
}
if(str[i]=='+'||str[i]=='-'||str[i]=='
'||str[i]=='/')
{
Push(s,str[i]);
continue;
}
if(str[i]==')')
{
printf("%c",str[i]);
Pop(s,x);
printf("%c",x);
continue;
}
i++;
}

}

void InitStack(struct Stack *s)
{
(*s).top=-1;
}
bool Push (struct Stack *s,Elemtype x)
{
if((*s).top==MaxSize-1)
return false;
(*s).data[++(*s).top]=x;
return true;
}
bool Pop (struct Stack *s,Elemtype *x)
{
if((*s).top==-1)
return false;
x=(*s).data[(*s).top--];
return true;
}

求大神改正,没报错,但是一跑就崩溃(因为题目说了输入的前缀一定正确,就没判断)

http://www.cnblogs.com/breakthings/p/4053444.html