if(s->data==2) printf("%c",s->data2); s=s->prior; }
qianzhuiqiuzhi(head2,n); printf("=%d ",n); }
int main() { char n[10]; char c;
int i,j,k,a,b,z,y,e; Lnode *p,*q,*first;
i=0;e=1;a=0;b=1;z=0;y=0;
p=(Lnode*)malloc(sizeof(struct Node)); first=p;
printf("请输入中缀表达式"); do
{ c = getchar();
if('0'<=c&&c<='9') { n[i]=c; i++; } else
{ switch (c)
{ case '+': case '-': case '*': case '/': case '%': case '(': case ')': case '\\n':
{ if(n[0]>'0'&&n[0]<='9') { q=(Lnode*)malloc(sizeof(struct Node)); p->next=q;
p=p->next; for(k=0;k<i;k++)
{ for(j=0;j<=i-k-2;j++) e=e*10;
a=a+(n[k]-'0')*e; e=1;
n[k]='0'; }
p->data=1; p->data1=a; i=0;a=0; }
if(c!='\\n') { if(p->data==2)
{ if(p->data2!=')'&&c!='(') b=0; }
q=(Lnode*)malloc(sizeof(struct Node)); p->next=q; p=p->next; p->data=2; p->data2=c;
if(c=='(') z++; if(c==')') y++; } }
default:
if(c!='+'&&c!='-'&&c!='*'&&c!='/'&&c!='%'&&c!='\\n'&&c!='('&&c!=')') b=0; } }
}while (c != '\\n'); if(z!=y) b=0;
p->next=NULL; if(b==0)
printf("输入中缀表达式有误"); else
{printf("输入1中缀表达式求值,输入2后缀表达式求值,输入3前缀表达
式求值");
scanf("%d",&b); if(b==1) zhongzhui(first); if(b==2) houzhui(first); if(b==3) qianzhui(first); }
return 1; }