全文预览

数据结构课程设计报告

上传者:非学无以广才 |  格式:doc  |  页数:21 |  大小:0KB

文档介绍
malloc( sizeof (bttree)); p->data=str[i]; p->lchild=cre_tree(str,2*i+1,m); p->rchild=cre_tree(str,2*i+2,m); return p; }linklist *creatlist( int n)//建立链表函数{int k; int i=0; linklist *head,*r,*p; p=(linklist *)malloc( sizeof (linklist)); head=p; p->next=NULL; r=p; for (k=1;k<=n;k++) {p=(linklist *)malloc( sizeof (linklist)); p->next=NULL; r->next=p; r=r->next; }return (head); }void inorder(bttree *t) //中序遍历二叉树函数{if(t!=NULL) {inorder(t->lchild); if(t->lchild==NULL&&t->rchild==NULL) {a[i]=t->data; cout<<a[i]<<endl; i++; }inorder(t->rchild); t=t->lchild; }} void fun 1() {char str[max]; int i,n,k;linklist *p,*head; bttree *root; head=NULL; cout<< "please intput abitree node num:" <<endl; cin>>n; getchar(); cout<< "please input astring which length is"<<n<<endl; for (i=0;i<n;i++) str[i]=getchar();

收藏

分享

举报
下载此文档