二叉搜索树驱动文件C++

    技术2022-05-13  23

      一晃一个月没有写东西,全是因为更多的精力放到了C++上.从5月4号开始的,马上就一个月了.虽然还没有学完,但也能写出像二叉搜索树这样的东西了.

      新特性好多好多,功能好多,提供给用户的接口更简单.内部实现很复杂.构造函数,复制构造函数,重载赋值运算符,各种各种...通过写这个东西小试身手下,再一个,到六月份了,一篇博客也没发表也不好看不是.

      就不多说了,在网吧,旁边有人...不想被看到写了什么,呵呵.

    贴咯~


    // 13-1-2011-06-01-21.17.cpp -- 第十三章思考题一 #include "stdafx.h" #include "13-1.h" #include <iostream> #include <cstdlib> #include <ctime> const int SIZE = 20 ; int _tmain(int argc, _TCHAR* argv[]) { using namespace :: binarySearchTree ; using std :: cout ; using std :: endl ; BinarySearchTree t ; srand (time (0)) ; Item * test ; test = new Item[SIZE] ; for (int i = 0; i < SIZE; ++i) { test[i] = rand () % SIZE ; t.Insert (test[i]) ; } BinarySearchTree newT = t ; BinarySearchTree testT ; for (int i = 0; i < SIZE; ++i) { test[i] = rand () % SIZE ; testT.Insert (test[i]) ; } testT.PrecedingOrderTreversal () ; cout << endl ; testT = newT ; testT.PrecedingOrderTreversal () ; cout << endl ; newT.PrecedingOrderTreversal () ; cout << endl ; for (int i = 0; i < SIZE; ++i) { t.Delete (test[i]) ; newT.Delete (test[i]) ; testT.Delete (test[i]) ; } delete []test ; std :: cin.get () ; return 0 ; }


    最新回复(0)