using namespace std;
The template & lt; Typename T>
The class Bintree;
The template & lt; Typename T>
The class Binode
{
Friend class Bintree
Public:
T data;
Binode
Binode
Binode item (T) {data=https://bbs.csdn.net/topics/item; Lchild=NULL; Rchild=NULL; }
~ Binode () {}
};
The template & lt; Typename T>
The class Bitree
{
Private:
Int size;
Public:
Binode
Bitree () {size=0; The root=NULL; Cout<& lt;" According to the antecedent sequence input: "& lt;
Void CreatTree (Binode
Void Preorder (Binode
Void Inorder (Binode
Void Postorder (Binode
Void Leverorder (Binode
Binode
};
The template & lt; Typename T>
Bitree
{
}
The template & lt; Typename T>
Void Bitree
{
char ch;
Cin> Ch;
If (ch=='#') curnode=NULL;
The else {
Curnode=new Binode
Curnode - & gt; data=https://bbs.csdn.net/topics/ch;
CreatTree (curnode - & gt; Lchild);
CreatTree (curnode - & gt; Rchild);
}
}
The template & lt; Typename T>
Void Bitree
{
Cout
Preorder (root - & gt; Rchild);
}
Int main ()
{
Bitree
Cout<& lt;" Creating a successful "& lt;
}
Input and operation results:
How can not C output?
CodePudding user response:
Big help!!!!!!CodePudding user response:
First order code wrong.You don't have to judge whether the current node is NULL, it still recursion bottom go to, must be wrong
CodePudding user response:
Understand the understand the stupid