求C++二叉树的程序,回答前请自己先试试

来源:百度知道 编辑:UC知道 时间:2024/05/23 02:14:25
#include<iostream.h>
最上面改成这样才能用

怎么可能没用呢?我调试过的

输入树的节点,0退出
9 8 7 5 9 8 1 6 9 0
1
5
6
7
8
8
9
9
9
Press any key to continue...

/////////////////////////////////////////////////////////////////////////////////////

#include<iostream>
#include<stdlib.h>

typedef struct tree
{
struct tree *left;
int date;
struct tree *right;
}treenode,*b_tree;
///////插入节点/////////////////////

b_tree insert(b_tree root,int node)
{
b_tree newnode;
b_tree currentnode;
b_tree parentnode;

newnode=(b_tree)malloc(sizeof(treenode));

newnode->date=node;
newnode->right=NULL;
newnode->left=NULL;

if(root==NULL)
return newnode;
else
{
currentnode=root;
while(currentnode!=NULL)