| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 539 人关注过本帖
标题:二叉树报错,解决不了
只看楼主 加入收藏
cwl168
Rank: 1
等 级:新手上路
帖 子:48
专家分:0
注 册:2012-12-14
结帖率:8.33%
收藏
 问题点数:0 回复次数:3 
二叉树报错,解决不了
#include<stdio.h>
#include<stdlib.h>
#include <malloc.h>

#define ERROR 0
#define OK 1


typedef int ElemType;

typedef struct BinaryTree

{
  ElemType data;
  struct BinaryTree *l;
  struct BinaryTree *r;
}*BiTree,BiNode;

BiNode * new()
{
  return( (BiNode *)malloc(sizeof(BiNode)) );
}

CreateSubTree(BiTree *T,ElemType *all,int i)
{
  if ((all[i]==0)||i>16)
    {
      *T=NULL;
      return OK;
    }
  *T=new();
  if(*T==NULL) return ERROR;
  (*T)->data=all[i];
  CreateSubTree(&((*T)->l),all,2*i);
  CreateSubTree(&((*T)->r),all,2*i+1);
}

CreateBiTree(BiTree *T)
{
  ElemType all[16]={0,1,2,3,0,0,4,5,0,0,0,0,6,0,0,0,};
  CreateSubTree(T,all,1);
}

printelem(ElemType d)
{
  printf("%d\n",d);
}

PreOrderTraverse(BiTree T,int (*Visit)(ElemType d))
{
  if(T){
    if(Visit(T->data))
      if(PreOrderTraverse(T->l,Visit))
    if(PreOrderTraverse(T->r,Visit)) return OK;
    return ERROR;
  } else  return OK;
}
main()
{
  BiTree root;
  CreateBiTree(&root);
  PreOrderTraverse(root,printelem);

}
为什么会报错
--------------------Configuration: 二叉树的链式存储实现方法 - Win32 Debug--------------------
Compiling...
二叉树的链式存储实现方法.cpp
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(19) : error C2059: syntax error : 'new'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(20) : error C2143: syntax error : missing ';' before '{'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(20) : error C2447: missing function header (old-style formal list?)
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(31) : error C2059: syntax error : ')'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : error C2143: syntax error : missing ';' before '}'
c:\users\administrator.pc-20120409npba\desktop\上机\自己写的代码\二叉树的链式存储实现方法\二叉树的链式存储实现方法.cpp(36) : fatal error C1003: error count exceeds 100; stopping compilation
执行 cl.exe 时出错.

二叉树的链式存储实现方法.obj - 1 error(s), 0 warning(s)

搜索更多相关主题的帖子: all include return 二叉树 
2012-12-20 15:26
yuccn
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:何方
等 级:版主
威 望:167
帖 子:6814
专家分:42393
注 册:2010-12-16
收藏
得分:0 
这样可以编译通过了。把你的new改成newObj 修改了几个返回值

#include<stdio.h>
#include<stdlib.h>
#include <malloc.h>

#define ERROR 0
#define OK 1


typedef int ElemType;

typedef struct BinaryTree

{
    ElemType data;
    struct BinaryTree *l;
    struct BinaryTree *r;
}*BiTree,BiNode;

BiNode * newObj()
{
    return( (BiNode *)malloc(sizeof(BiNode)) );
}


int CreateSubTree(BiTree *T,ElemType *all,int i)
{
    if ((all[i]==0)||i>16)
    {
        *T=NULL;
        return OK;
    }
    *T=newObj();
    if(*T==NULL) return ERROR;
    (*T)->data=all[i];
    CreateSubTree(&((*T)->l),all,2*i);
    CreateSubTree(&((*T)->r),all,2*i+1);

    return OK;
}

void CreateBiTree(BiTree *T)
{
    ElemType all[16]={0,1,2,3,0,0,4,5,0,0,0,0,6,0,0,0,};
    CreateSubTree(T,all,1);
}

int printelem(ElemType d)
{
    printf("%d\n",d);

    return 0;
}

int PreOrderTraverse(BiTree T,int (*Visit)(ElemType d))
{
    if(T){
        if(Visit(T->data))
            if(PreOrderTraverse(T->l,Visit))
                if(PreOrderTraverse(T->r,Visit)) return OK;
        return ERROR;
    } else  return OK;
}
void main()
{
    BiTree root;
    CreateBiTree(&root);
    PreOrderTraverse(root,printelem);
}

我行我乐
公众号:逻辑客栈
我的博客:
https://blog.yuccn. net
2012-12-22 10:19
yuccn
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:何方
等 级:版主
威 望:167
帖 子:6814
专家分:42393
注 册:2010-12-16
收藏
得分:0 
命名文件 别用中文哦,不好的习惯。

用英文命名,不懂可以icba查询。

我行我乐
公众号:逻辑客栈
我的博客:
https://blog.yuccn. net
2012-12-22 10:19
cwl168
Rank: 1
等 级:新手上路
帖 子:48
专家分:0
注 册:2012-12-14
收藏
得分:0 
这样创建二叉树不是很懂,能指点一二吗?
2012-12-22 15:09
快速回复:二叉树报错,解决不了
数据加载中...
 
   



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

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