| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 822 人关注过本帖
标题:二叉树的问题
只看楼主 加入收藏
guang
Rank: 4
来 自:广东深圳
等 级:贵宾
威 望:13
帖 子:1414
专家分:285
注 册:2006-4-3
结帖率:100%
收藏
 问题点数:0 回复次数:4 
二叉树的问题

不知怎么改了:
#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)

搜索更多相关主题的帖子: 二叉树 
2006-11-07 10:54
guang
Rank: 4
来 自:广东深圳
等 级:贵宾
威 望:13
帖 子:1414
专家分:285
注 册:2006-4-3
收藏
得分:0 
都没人懂吗?各位高手帮帮我呀!

不相信未作牺牲竟先可拥有,只相信靠双手找到我的欲求!!
我的博客:http://liao5930.blog.
2006-11-07 15:41
热情依然
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:22
帖 子:715
专家分:0
注 册:2005-4-5
收藏
得分:0 
不知道你想问什么,你可以在本板块找到你所需要的二叉树程序

c++/C + 汇编 = 天下无敌
2006-11-07 16:05
菜鸟上路
Rank: 4
等 级:贵宾
威 望:14
帖 子:1120
专家分:0
注 册:2006-3-21
收藏
得分:0 

把JD *bt,*p,*q,s[M];改成JD bt,p,q,s[M];试试


2006-11-07 16:05
lpzhouyang
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2006-9-8
收藏
得分:0 
e:\c++学习\数据结构\二叉树\cpp1.cpp(47) : error C2065: 'sttin' : undeclared identifier
应该是 fflush(stdin)
其余的问题应该和楼上说的差不多,你试试,我没调试过,不过应该可以
2006-11-08 23:32
快速回复:二叉树的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020182 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved