main.cpp

来自「中序线索化的二叉树 能够对二叉树先线索化然后再中序排列 并且输出」· C++ 代码 · 共 40 行

CPP
40
字号
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "treeabc.h"
#include "avl.h"
#include "print.h"
#include "thread.h"
using namespace std;

int main()
{
     int i;
     AVLTree* pRoot = NULL;

     srand((unsigned int)::time(NULL));
    
     for (i = 0; i < 10; ++i)
     {
         pRoot = Insert(::rand(), pRoot);
     }

     PrintTree(pRoot);


     BiTree = (AVLTree *)malloc(sizeof(AVLTree));
      //cout<<"输入节点数据(char 型)(#代表NULL):"<<endl;
      //BiTree = CreateBiTree(BiTree);
     BiTree = InOrderThreading(pRoot);
     cout<<"线索化后遍历输出:"<<endl;
     InOrderTraverse(pRoot);
     cout<<"pRoot指针的value是:"<<pRoot->nData<<"  nHeight值为:"<<pRoot->nHeight<<endl;
     cout<<"pRoot指针的左子的value是"<<pRoot->pLeft->nData<<"  nHeight值为:"<<pRoot->pLeft->nHeight<<endl;
     //printBTree(pRoot);
     //DeleteTree(&pRoot);

     
     system("pause");
     return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?