2 baidu 24427837 baidu_24427837 于 2014.12.11 18:37 提问

求各位哥哥姐姐帮帮忙啊,这个程序哪里错了
c

#include
#include
typedef struct Binnode
{
char data;
struct Binnode lchild;
struct Binnode *rchild;
};
typedef Binnode *Bintree ;
typedef struct stack
{
Bintree data[100];
int flag[100];
int top;
};
typedef struct queue
{
Bintree data[30];
int front;
int rear;
};
void Creat_Bintree(Bintree *root)
{
char ch;
if((ch=getchar())==' ')
{
*root=NULL;
}
else
{
*root=(Binnode
)malloc(sizeof(Binnode));
(*root)->data=ch;
Creat_Bintree(&(*root)->lchild);
Creat_Bintree(&(*root)->rchild);
}
}
void Preorder1(Bintree t)
{
if(t!=NULL)
{
printf("%c",t->data);
Preorder1(t->lchild);
Preorder1(t->rchild);
}
}
void Inorder1(Bintree t)
{
if(t!=NULL)
{
Inorder1(t->lchild);
printf("%c",t->data);
Inorder1(t->rchild);
}
}
void Posorder1(Bintree t)
{
if(t!=NULL)
{
Posorder1(t->lchild);
Posorder1(t->rchild);
printf("%c",t->data);
}
}
void Levelorder(Bintree t)
{
queue q;
q.data[0]=t;
q.front=0;q.rear=1;
printf("层次遍历二叉树结果:");
while(q.front {
if(q.data[q.front])
{
printf("%c",q.data[q.front]->data);
q.data[q.rear++]=q.data[q.front]->lchild;
q.data[q.rear++]=q.data[q.front]->rchild;
q.front++;
}
else
{
q.front++;
}
}
printf("\n\n");
}
#include"Bintree.h"
void Exchange1(Bintree t)
{
Bintree temp;
if(t)
{
Exchange1(t->lchild);
Exchange1(t->rchild);
temp=t->lchild;
t->lchild=t->rchild;
t->rchild=temp;
}
}
#include"Bintree.h"
int Leaves_Num1(Bintree t)
{
if(t)
{
if(t->lchild==NULL&&t->rchild==NULL)
{
return 1;
}
return Leaves_Num1(t->lchild)+Leaves_Num1(t->rchild);
}
return 0;
}
int main()
{
int count=0;
Bintree t;
Creat_Bintree(&t);
count=Leaves_Num2(t);
printf("该二叉树的叶子结点数为:%d\n",count);
return 0;
}

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!