⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 prg10_3.cpp

📁 这是数据结构和算法的国外经典书籍.清华大学出版社出版的<数据结构C++语言描述-应用模板库STL>陈君 译 英文名称是Data Structures with C++ Using STL.
💻 CPP
字号:
// File: prg10_3.cpp
// the program builds the sample Tree 2 and displays the tree.
// by using copyTree(), the program makes a copy of Tree 2,and
// displays the copied tree. the program terminates after using
// clearTree() to delete the nodes in both trees

#include <iostream>

#include "d_tnode.h"		// tnode class
#include "d_tnodel.h"	// tnode library

using namespace std;

int main()
{
	// roots for two trees
	tnode<char> *root1, *root2;

	// build the character Tree 2 with root root2
	root1 = buildTree(2);

	// display the tree
	cout << "Original tree (Tree 2)" << endl;
	displayTree(root1, 1);
	cout << endl << endl;

	// make a copy of root1 so its root is root2
	root2 = copyTree(root1);

	// display the tree copy
	cout << "Copy of Tree 2" << endl;
	displayTree(root2, 1);
	cout << endl;

	// delete the nodes in the two trees
	clearTree(root1);
	clearTree(root2);

	return 0;
}

/*
Run:

Original tree (Tree 2)
       A
     B         C
 D         E     F
   G     H   I


Copy of Tree 2
       A
     B         C
 D         E     F
   G     H   I
*/

⌨️ 快捷键说明

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