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

📄 exam7-1.cpp

📁 数据结构c++-书的一些源代码
💻 CPP
字号:
#include <iostream.h>

#include "BiTreeNode.h"
#include "BiTreeTraverse.h"

void MakeCharTree(BiTreeNode<char>*  &root)
{
	BiTreeNode<char> *b, *c, *d, *e, *f, *g, *null = NULL;

	g = GetTreeNode('G');
	d = GetTreeNode('D', null, g);
	b = GetTreeNode('B', d);
	e = GetTreeNode('E');
	f = GetTreeNode('F');
	c = GetTreeNode('C', e, f);
	root = GetTreeNode('A', b, c);
}

void Printchar(char item)
{
	cout << item << " ";
}

void main(void)
{
	BiTreeNode<char> *root1, *p;

	MakeCharTree(root1);
	cout << "二叉树为:" << endl;
	PrintBiTree(root1, 0);

	cout << "\n前序遍历结点次序为: ";
	PreOrder(root1, Printchar);

	cout << "\n中序遍历结点次序为: ";
	InOrder(root1, Printchar);

	cout << "\n后序遍历结点次序为: ";
	PostOrder(root1, Printchar);

	p = Search(root1, 'C');
	if(p != NULL)
		cout << "\n查找到的结点数据值为:" << p->data;
	else
		cout << "\n查找失败";

	cout << "\n撤消结点次序为: ";
	Destroy(root1);
}

⌨️ 快捷键说明

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