e13-01.cpp
来自「游戏开发数据结构Data Structures for Game Program」· C++ 代码 · 共 41 行
CPP
41 行
// =======================================================
// Chapter 13, Example 1
// Playing around with Binary Search Trees
// =======================================================
#include <iostream.h>
#include <stdio.h>
#include "BinarySearchTree.h"
int CompareInts( int left, int right )
{
return left - right;
}
void main()
{
BinarySearchTree<int> tree( CompareInts );
BinaryTree<int>* node;
// insert data
tree.Insert( 8 );
tree.Insert( 4 );
tree.Insert( 12 );
tree.Insert( 2 );
tree.Insert( 6 );
tree.Insert( 10 );
tree.Insert( 14 );
// these searches are successful
node = tree.Find( 8 );
node = tree.Find( 2 );
node = tree.Find( 14 );
node = tree.Find( 10 );
// these searches return 0
node = tree.Find( 1 );
node = tree.Find( 3 );
node = tree.Find( 5 );
node = tree.Find( 7 );
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?