预览加载中,请您耐心等待几秒...
1/7
2/7
3/7
4/7
5/7
6/7
7/7

在线预览结束,喜欢就下载吧,查找使用更方便

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

#include<stdio.h> #include<stdlib.h> #defineNUM50 typedefcharDatatype; typedefstructNode*Pnode; structNode{ Datatypeinfo; Pnodellink; Pnoderlink; }; structSeqstack{ intmaxnum; intn; Pnode*element; }; typedefstructSeqstack*Pseqstack; typedefstructNode*Bintree; typedefBintree*Pbintree; voidVisit(Bintreet){ printf("Thenodeis:%c\n",t->info); } BintreeRoot(Bintreet){ returnt; } BintreeLeftchild(Bintreet){ return(t->llink); } BintreeRightchild(Bintreet){ return(t->rlink); } //Stack PseqstackCreateemptystack(intm){ Pseqstackpastack=(Pseqstack)malloc(sizeof(structSeqstack)); if(pastack!=NULL){ pastack->element=(Pnode*)malloc(sizeof(Pnode)*m); if(pastack->element){ pastack->maxnum=m; pastack->n=-1; return(pastack); } elsefree(pastack); } printf("Outofspace!\n"); returnNULL; } intIsnullstack(Pseqstackpastack){ return(pastack->n==-1); } voidPushseqstack(Pseqstackst,Pnodex){ if(st->n+1>=st->maxnum){ printf("overflow!\n"); return; } st->n+=1; st->element[st->n]=x; } PnodeTopseqstack(Pseqstackst){ if(Isnullstack(st)) printf("Emptystack!\n"); else return(st->element[st->n]); } voidPopseqstack(Pseqstackst){ if(Isnullstack(st)){ printf("Underflow!\n"); } elsest->n--; } voidCreate(Pnodet){ Pnodetemp; if(t==NULL)return; temp=malloc(sizeof(structNode)); temp->llink=NULL; temp->rlink=NULL; t->llink=temp; printf("Theleftchildofnode%cis:",t->info); t->llink->info=getchar();getchar(); if(t->llink->info==''){ free(temp); //free(t->llink); t->llink=NULL; } Create(Leftchild(t)); temp=malloc(sizeof(structNode)); temp->llink=NULL; temp->llink=NULL; t->rlink=temp; printf("Therightchildofnode%cis:",t->info); t->rlink->info=getchar();getchar(); if(t->rlink->info==''){ free(temp); //free(t->rlink); t->rlink=NULL; } Create(Rightchild(t)); } /*voidCreate(Pnodet){ if(t->info=='*')return; templ=malloc(sizeof(structNode));t->llink=templ; printf("Theleftchildofnode%cis:ifnull,use*\n",); t->llink->info=getchar();getchar(); Create(Leftch