#include <iostream>
#include <cstdlib>
using namespace std;
struct BinTreeNode{
int date;
BinTreeNode *liftChild, *rightChild;
}
class BinaryTree{
public:
BinaryTree();
BinaryTree(BinaryTree &s);
~BinaryTree();
void CreateBinTree(BinTreeNode *&SubTree);
bool IsEmpty();
void InOrder();
void InOrder(BinTreeNode *subTree);
void PreOrder();
void PreOrder(BinTreeNode *subTree);
void PostOrder();
void PostOrder(BinTreeNode *subTree);
int Count();
int Count(BinTreeNode *subTree);
private:
BinTreeNode *root;
};
//构造函数
BinaryTree::BinaryTree():root(NULL){}
BinaryTree::BinaryTree(BinaryTree &s){
}
//判空
bool BinaryTree::IsEmpty(){
return root == NULL ? true : false;
}
//中序遍历
void BinaryTree::InOrder(){
InOrder(root);
}
void BinaryTree::InOrder(BinTreeNode *subTree){
if(subTree != NULL){
InOrder(subTree->liftChild);
cout << subTree->date;
InOrder(subTree->rightChild);
}
}
//先序遍历
void BinaryTree::PreOrder(){
PreOrder(root);
}
void BinaryTree::PreOrder(BinTreeNode *subTree){
if(subTree != NULL){
cout << subTree->date;
PreOrder(subTree->liftChild);
PreOrder(subTree->rightChild);
}
}
//后续遍历
void BinaryTree::PostOrder(){
PostOrder(root);
}
void BinaryTree::PostOrder(BinTreeNode *subTree){
if(subTree != NULL){
PostOrder(subTree->liftChild);
PostOrder(subTree->rightChild);
cout << subTree->date;
}
}
int main(){
system("pause");
return 0;
}