请教一般的二叉树
好象在void creat(node *bt,char a)里有个逻辑上的错误
希望大家帮帮忙 帮我找一下
谢谢大家了
#include<iostream.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node
{
char data;
node *left,*right;
};
void creat(node *bt,char a)
{
node *p=new node;
p->data=a;
p->left=NULL;
p->right=NULL;
if(bt==NULL)
{
bt=p;
}
creat(bt->left,p->data);
creat(bt->right,p->data);
}
void intraverse(node *bt)
{
if(bt!=NULL)
{
intraverse(bt->left);
cout<<bt->data;
intraverse(bt->right);
}
}
void main()
{
char ch;
node *btt=0;
cout<<"please input the value of node."<<endl;
cin>>ch;
while((ch!='q')&&(cin.good()))
{
creat(btt,ch);
cin>>ch;
}
intraverse(btt);
cout<<endl;
}