想要構(gòu)造二叉樹函數(shù)及遍歷,以下操作該怎么修改嗎?
//主要是驗(yàn)證下采用遞推的算法對二叉樹進(jìn)行遍歷:#include<stdio.h>#include<stdlib.h>#include<malloc.h>//二叉樹的表示:#define error -1#define ok 1typedef struct BiTreeNode{//結(jié)點(diǎn)元素的數(shù)值:char data;struct BiTreeNode *lchild,*rchild;}Bnode,*Btree;//初始化一個(gè)二叉樹,int creatree(Btree T);//對二叉樹樹結(jié)點(diǎn)的操作函數(shù):int print(char e);//遍歷二叉樹結(jié)點(diǎn):先序遍歷法int preoder(Btree T,int(*vist)(char));//遍歷二叉樹結(jié)點(diǎn):中序遍歷法int inorder(Btree T,int(*vist)(char));//遍歷二叉樹結(jié)點(diǎn):后序遍歷法int postorder(Btree T,int(*vist)(char));//主函數(shù):int main(int argc,char *argv[]){Btree R;int i,j;R=(Btree)malloc(sizeof(Bnode));i=creatree(R);printf("if i=1;表示初始化成功:%d\n",i);j=preoder(R,print);printf("if j=1;表示初始化成功:%\n",j);printf("\n");inorder(R,print);printf("\n");postorder(R,print);return 0;}//初始化一個(gè)二叉樹:int creatree(Btree T){//按先后順序輸入二叉樹結(jié)點(diǎn)值,空格表示空樹:char ch;printf("輸入字符\n");scanf("%c",&ch);if(ch==' ')T=NULL;else{if(!(T=(Bnode*)malloc(sizeof(Bnode))))return error;T->data=ch;creatree(T->lchild);creatree(T->rchild);}return ok;}//int print(char e){printf("%c\n",e);return ok;}//int preoder(Btree T,int(*vist)(char)){if(T){vist(T->data);preoder(T->lchild,vist);preoder(T->rchild,vist);return ok;}elsereturn error;}//int inorder(Btree T,int(*vist)(char)){if(T){inorder(T->lchild,vist);vist(T->data);inorder(T->rchild,vist);return ok;}elsereturn error;}int postorder(Btree T,int(*vist)(char)){if(T){postorder(T->lchild,vist);postorder(T->rchild,vist);vist(T->data);return ok;}elsereturn error;}怎么這個(gè)函數(shù)調(diào)試不出來,,在vc調(diào)試下,,卡在這里:vist(T->data);
查看完整描述