热门

最新

红包

立Flag

投票

同城

我的

发布
u014161864
arbboter
4 年前
trueu014161864

不要做一个只提问题,却不解决问题的人。

CSDN App 扫码分享
分享
评论
2
打赏
  • 复制链接
  • 举报
下一条:
#include<stdio.h>#include<math.h>#include<stdlib.h>#include<malloc.h>#include<ctype.h>#define StackInitSize 100#define max 20#define lenBiTree sizeof(struct biTree)//二叉树节点typedef struct biNode{ char data; struct biNode *lchild; struct biNode *rchild;}biNode,*biTree;void ReadExpr(biTree *E){ char ch; scanf("c%",&ch); *E=(biTree)malloc(sizeof(biNode)); (*E)->data=ch; if((ch>='0'&&ch<='9')||(ch>='a'&&ch<='z')){ (*E)->lchild=NULL; (*E)->rchild=NULL; } else{ ReadExpr(&(*E)->lchild); ReadExpr(&(*E)->rchild); }}void WriteExpr(biTree *E){ if((*E)->lchild!=NULL){ printf("("); WriteExpr(&(*E)->lchild); } if(E!=NULL){ printf("%c",(*E)->data); } if((*E)->rchild!=NULL){ WriteExpr(&(*E)->rchild); printf(")"); }}int main(){ biTree *E; printf("输入表达式:\n"); ReadExpr(E); WriteExpr(E);}
立即登录