/**/ /*中序表达转换成后序表达式的方法:从左到右读取该中弱序表达式:1.若是操作数,则直接输出.2.若是运算符:(1)若该运算符为"(",则直接入栈.(2)若该运算符为")",则取出堆栈中的运算符,直到"("时.(3)其它: 按优先级比较,如果大于或等于堆栈中当前的运算则压入栈中,否则直接输出.(4)检查栈是否非空,如果非空,则输出所有值,直到空为止.*/ #include < stdio.h > #include < stdlib.h > #include < string .h > #include < ctype.h > #define MAX 101 /*表达式的最大长度*/ typedef struct optor ... { char ch ; struct optor *next ;} OPT ; /**/ /*typedef struct data{ int num ; struct data *next ;}DAT ;*/ OPT * opttop = NULL ; /**/ /*初始堆栈*/ /**/ /* DAT *dattop = NULL ;*/ void push_opt( int cx) ... { OPT *q ; q = (OPT *)malloc(sizeof(OPT)) ; q->ch = cx ; q->next= opttop; opttop = q ;} char top_opt( void ) ... { if(opttop) return opttop->ch ; return '#' ;} void pop_opt() ... { OPT *q ; q = opttop ; opttop = opttop->next ; free(q);} int rank( char cr) ... { if( cr == '-' || cr == '+') return 1 ; else if( cr == '*' || cr == '/') return 2 ; else if( cr == '^') return 3 ;} int main( void ) ... { char st[MAX]=...{'