不知怎么改了:
#include <iostream.h>
#include <stdlib.h>
#include <stdio.h>
#define M 10
typedef struct node
{
char data;
struct node *lc,*rc;
}JD;
void dxxbl(JD *r)
{
if(r!=NULL)
{
cout<<r->data;
dxxbl(r->lc);
dxxbl(r->rc);
}
}
void dzxbl(JD *r)
{
if(r!=NULL)
{
dzxbl(r->lc);
cout<<r->data;
dzxbl(r->rc);
}
}
void dhxbl(JD *r)
{
if(r!=NULL)
{
dhxbl(r->lc);
dhxbl(r->rc);
cout<<r->data;
}
}
void main()
{
JD *bt,*p,*q,s[M];
char a,b,t;
int i=0,j=0;
bt=NULL;
cout<<"请输入二叉树左右儿子:"<<endl;
while(1)
{
fflush(sttin);
cin>>a>>b>>t;
if(b=='#') break;
if(a=='#')
{
p=(JD*)malloc(sizeof(JD));
p->data=b;
p->lc=NULL;
p->rc=NULL;
bt=p;
s[i++]=p;
}
else
{
p=(JD*)malloc(sizeof(JD));
p->data=b;
p->lc=NULL;
p->rc=NULL;
while(1)
{
q=s[j];
if(q->data==a)
{
if(t=='l')
q->lc=p;
else q->rc=p;
s[i++]=p;
break;
}
else
{
s[j]=NULL;
j++;
}
}
}
}
cout<<"\n二叉树的先序遍历:"<<endl;
dxxbl(bt);
cout<<"\n二叉树的中序遍历:"<<endl;
dzxbl(bt);
cout<<"\n二叉树的后序遍历:"<<endl;
dhxbl(bt);
}
e:\c++学习\数据结构\二叉树\cpp1.cpp(47) : error C2065: 'sttin' : undeclared identifier
e:\c++学习\数据结构\二叉树\cpp1.cpp(57) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'struct node *' (or there is no acceptable conversion)
e:\c++学习\数据结构\二叉树\cpp1.cpp(67) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'struct node' (or there is no acceptable conversion)
e:\c++学习\数据结构\二叉树\cpp1.cpp(73) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'struct node *' (or there is no acceptable conversion)
e:\c++学习\数据结构\二叉树\cpp1.cpp(78) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'const int' (or there is no acceptable conversion)
Error executing cl.exe.
Cpp1.exe - 5 error(s), 0 warning(s)