idk why these stuffs get stashed for so long and I didn't ever commit them
This commit is contained in:
138
Chapter5/BiTree/BiTree.vcxproj
Normal file
138
Chapter5/BiTree/BiTree.vcxproj
Normal file
@@ -0,0 +1,138 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>17.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{904cfcdf-da23-415a-8d68-8e51ad913458}</ProjectGuid>
|
||||
<RootNamespace>BiTree</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="bitree.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="bitree.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
27
Chapter5/BiTree/BiTree.vcxproj.filters
Normal file
27
Chapter5/BiTree/BiTree.vcxproj.filters
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="源文件">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="头文件">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="资源文件">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="bitree.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="bitree.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
129
Chapter5/BiTree/bitree.cpp
Normal file
129
Chapter5/BiTree/bitree.cpp
Normal file
@@ -0,0 +1,129 @@
|
||||
#include<iostream>//cout,cin
|
||||
#include<string>
|
||||
using namespace std;
|
||||
#include"bitree.h"
|
||||
|
||||
//测试参考数据
|
||||
string fbt = "a b d # # e # # c f # # g # #"; // 满二叉树最后一层每个叶结点后有两个#
|
||||
string cbt = "a b d # # e # # c # #"; // 完全二叉树每个叶结点后有两个#
|
||||
string gbt = "a b # d # # c e # # #"; // 一般二叉树
|
||||
string obt = "a b c d # # # # #"; // 左斜树1
|
||||
|
||||
|
||||
void dispmenu()
|
||||
{ //显示主菜单
|
||||
cout << endl;
|
||||
cout << "1-创建二叉树\n";
|
||||
cout << "2-先序递归遍历二叉树\n";
|
||||
cout << "3-中序递归遍历二叉树\n";
|
||||
cout << "4-后序递归遍历二叉树\n";
|
||||
cout << "5-层序遍历二叉树\n";
|
||||
cout << "6-先序非递归遍历二叉树\n";
|
||||
cout << "7-中序非递归遍历二叉树\n";
|
||||
cout << "8-后序非递归遍历二叉树\n";
|
||||
cout << "9-结点查询\n";
|
||||
cout << "10-求二叉树高度\n";
|
||||
cout << "11-求二叉树结点个数\n";
|
||||
cout << "12-显示二叉树\n";
|
||||
cout << "0 -退出\n";
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int level;
|
||||
BTNode<char>* bt;
|
||||
|
||||
system("cls"); // 清屏
|
||||
|
||||
int choice;
|
||||
do
|
||||
{
|
||||
dispmenu(); // 显示主菜单
|
||||
cout << "Enter choice(1~12,0 退出):";
|
||||
cin >> choice;
|
||||
switch (choice)
|
||||
{
|
||||
case 1: // 创建二叉树
|
||||
cout << "测试参考数据:" << endl;
|
||||
cout << "满二叉树:" << fbt << endl;
|
||||
cout << "完全二叉树:" << cbt << endl;
|
||||
cout << "一般二叉树:" << gbt << endl;
|
||||
cout << "左斜二叉树:" << obt << endl;
|
||||
cout << "请按先序序列的顺序输入二叉树,#为空指针域标志:" << endl;
|
||||
CreateBiTree(bt);
|
||||
break;
|
||||
case 2: // 先序递归遍历二叉树
|
||||
cout << "先序遍历序列为:" << endl;
|
||||
PreOrDerBiTree(bt);
|
||||
break;
|
||||
case 3: // 中序递归遍历二叉树
|
||||
cout << "中序遍历序列为:" << endl;
|
||||
InOrDerBiTree(bt);
|
||||
cout << endl;
|
||||
break;
|
||||
case 4: // 后序递归遍历二叉树
|
||||
cout << "后序遍历序列为:" << endl;
|
||||
PostOrDerBiTree(bt);
|
||||
cout << endl;
|
||||
break;
|
||||
case 5: // 层序遍历二叉树
|
||||
cout << "层序遍历序列为:" << endl;
|
||||
cout << endl;
|
||||
LevelBiTree(bt);
|
||||
break;
|
||||
case 6: // 先序非递归遍历二叉树
|
||||
cout << "先序非递归遍历序列为:" << endl;
|
||||
PreOrderBiTree_N(bt);
|
||||
cout << endl;
|
||||
break;
|
||||
case 7: // 中序非递归遍历二叉树
|
||||
cout << "中序非递归遍历序列为:" << endl;
|
||||
InOrderBiTree_N(bt);
|
||||
cout << endl;
|
||||
break;
|
||||
case 8: // 后序非递归遍历二叉树
|
||||
cout << "后序非递归遍历序列为:" << endl;
|
||||
cout << endl;
|
||||
PostOrderBiTree_N(bt);
|
||||
break;
|
||||
case 9: // 结点查询
|
||||
char e;
|
||||
BTNode<char>* p;
|
||||
cout << "输入要查询的结点值:" << endl;
|
||||
cin >> e;
|
||||
p = Search(bt, e);
|
||||
if (p)
|
||||
{
|
||||
cout << "找到!";
|
||||
cout << p->data << endl;
|
||||
}
|
||||
else
|
||||
cout << "未找到!" << endl;
|
||||
cout << endl;
|
||||
break;
|
||||
case 10: // 求二叉树高度
|
||||
cout << "二叉树高度为:" << Depth(bt) << endl;
|
||||
cout << endl;
|
||||
break;
|
||||
case 11: //求二叉树结点个数
|
||||
cout << "二叉树结点数为:" << NodeCount(bt) << endl;
|
||||
cout << endl;
|
||||
break;
|
||||
case 12: // 显示二叉树
|
||||
cout << "2-显示二叉树" << endl;
|
||||
level = 1;
|
||||
DispBiTree(bt, level);
|
||||
cout << endl;
|
||||
break;
|
||||
case 0: // 退出
|
||||
DestroyBiTree(bt);
|
||||
cout << "结束运行Bye-Bye!" << endl;
|
||||
break;
|
||||
default: // 无效选择
|
||||
cout << "Invalid choice\n";
|
||||
break;
|
||||
}
|
||||
} while (choice != 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
421
Chapter5/BiTree/bitree.h
Normal file
421
Chapter5/BiTree/bitree.h
Normal file
@@ -0,0 +1,421 @@
|
||||
template <class DT>
|
||||
struct BTNode
|
||||
{
|
||||
DT data; //数据域
|
||||
BTNode* lchild; //指向左子树的指针
|
||||
BTNode* rchild; //指向右子树的指针
|
||||
};
|
||||
|
||||
//队列工具
|
||||
template <class DT>
|
||||
struct SqQueue // 顺序队类
|
||||
{
|
||||
BTNode<DT>** base; // 队列首址
|
||||
int front; // 队头指针
|
||||
int rear; // 队尾指针
|
||||
int queuesize; // 队容量
|
||||
};
|
||||
|
||||
//栈
|
||||
template <class DT>
|
||||
struct SqStack // 顺序栈
|
||||
{
|
||||
BTNode<DT>** base; // 栈首址
|
||||
int top; // 栈顶指针
|
||||
int stacksize; // 栈容量
|
||||
};
|
||||
|
||||
//算法5.1 先序遍历递归算法
|
||||
template <class DT>
|
||||
void PreOrDerBiTree(BTNode<DT>* bt)
|
||||
{
|
||||
if (bt != NULL)
|
||||
{
|
||||
cout << bt->data << ' '; //输出结点上的数据
|
||||
PreOrDerBiTree(bt->lchild); //递归的调用前序遍历左子树
|
||||
PreOrDerBiTree(bt->rchild); //递归的调用前序遍历右子树
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//算法5.2 中序遍历递归算法
|
||||
template <class DT>
|
||||
void InOrDerBiTree(BTNode<DT>* bt)
|
||||
{
|
||||
if (bt != NULL)
|
||||
{
|
||||
InOrDerBiTree(bt->lchild); //递归的调用中序遍历左子树
|
||||
cout << bt->data << ' '; //输出结点上的数据
|
||||
InOrDerBiTree(bt->rchild); //递归的调用中序遍历右子树
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//算法5.3 后序遍历递归算法
|
||||
template <class DT>
|
||||
void PostOrDerBiTree(BTNode<DT>* bt)
|
||||
{
|
||||
if (bt != NULL)
|
||||
{
|
||||
PostOrDerBiTree(bt->lchild); //递归的调用后序遍历左子树
|
||||
PostOrDerBiTree(bt->rchild); //递归的调用后序遍历右子树
|
||||
cout << bt->data << ' '; //输出结点上的数据
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//算法5.4 层序遍历算法
|
||||
template<class DT>
|
||||
void LevelBiTree(BTNode<DT>* bt)
|
||||
{
|
||||
SqQueue<DT> Q; // 创建一个队
|
||||
int m = 20;
|
||||
InitQueue(Q, m);
|
||||
BTNode<DT>* p;
|
||||
p = bt;
|
||||
if (p) EnQueue(Q, p); // 树非空,入队
|
||||
while (!QueueEmpty(Q)) // 队非空
|
||||
{
|
||||
DeQueue(Q, p); // 出队
|
||||
cout << p->data; // 访问
|
||||
if (p->lchild != NULL) // 有左孩子
|
||||
EnQueue(Q, p->lchild); // 左孩子入队
|
||||
if (p->rchild != NULL) // 有右孩子
|
||||
EnQueue(Q, p->rchild); // 右孩子入队
|
||||
}
|
||||
DestroyQueue(Q); // 销毁队列
|
||||
}
|
||||
|
||||
|
||||
//算法5.5 先序非遍历递归算法
|
||||
template <class DT>
|
||||
void PreOrderBiTree_N(BTNode<DT>* bt)
|
||||
{
|
||||
SqStack<DT> S; // 创建栈
|
||||
int m = 20;
|
||||
InitStack(S, m);
|
||||
BTNode<DT>* p;
|
||||
p = bt;
|
||||
while (p != NULL || !StackEmpty(S)) // 树非空或栈非空
|
||||
{
|
||||
while (p != NULL) // 结点非空
|
||||
{
|
||||
cout << p->data << ' '; // 访问结点
|
||||
Push(S, p); // 入栈
|
||||
p = p->lchild; // 转左子树
|
||||
}
|
||||
if (!StackEmpty(S)) // 栈非空
|
||||
{
|
||||
Pop(S, p); // 出栈
|
||||
p = p->rchild; // 转出栈结点的右子树
|
||||
}
|
||||
}
|
||||
DestroyStack(S); //销毁栈
|
||||
}
|
||||
|
||||
|
||||
//算法5.6 中序非遍历递归算法
|
||||
template <class DT>
|
||||
void InOrderBiTree_N(BTNode<DT>* bt)
|
||||
{
|
||||
SqStack<DT> S; // 创建一个栈
|
||||
int m = 20;
|
||||
InitStack(S, m);
|
||||
BTNode<DT>* p;
|
||||
p = bt;
|
||||
while (p != NULL || !StackEmpty(S)) // 结点非空或栈非空
|
||||
{
|
||||
while (p != NULL) // 结点非空
|
||||
{
|
||||
Push(S, p); // 入栈
|
||||
p = p->lchild; // 转出栈结点右子树
|
||||
}
|
||||
if (!StackEmpty(S)) // 栈非空
|
||||
{
|
||||
Pop(S, p); // 出栈
|
||||
cout << p->data << ' '; // 访问出栈结点
|
||||
p = p->rchild; // 转出栈结点的右子树
|
||||
}
|
||||
}
|
||||
DestroyStack(S); // 销毁栈
|
||||
}
|
||||
|
||||
|
||||
|
||||
//算法5.7 后序非遍历递归算法
|
||||
template <class DT>
|
||||
void PostOrderBiTree_N(BTNode<DT>* bt)
|
||||
{
|
||||
SqStack<DT> S; // 创建一个栈
|
||||
int m = 20;
|
||||
InitStack(S, m);
|
||||
BTNode<DT>* p;
|
||||
BTNode<DT>* r;
|
||||
p = bt;
|
||||
bool flag;
|
||||
do
|
||||
{
|
||||
while (p) // 结点非空
|
||||
{
|
||||
Push(S, p); // 结点入栈
|
||||
p = p->lchild; // 转左子树
|
||||
}
|
||||
r = NULL; // 指向刚被访问点,初值为空
|
||||
flag = true; // true表示处理栈顶结点
|
||||
while (!StackEmpty(S) && flag) // 栈非空且当前处理的是栈顶结点
|
||||
{
|
||||
GetTop(S, p); // 获取栈顶元素
|
||||
if (p->rchild == r) // 如果 当前结点是栈元素的右孩子
|
||||
{
|
||||
cout << p->data << ' '; // 访问栈顶元素
|
||||
Pop(S, p); // 出栈
|
||||
r = p; // r指向被访问结点
|
||||
}
|
||||
else // 否则
|
||||
{
|
||||
p = p->rchild; // 转栈顶元素右孩子
|
||||
flag = false; // 处理非栈顶结点
|
||||
}
|
||||
}
|
||||
} while (!StackEmpty(S)); // 栈非空,循环
|
||||
cout << endl;
|
||||
DestroyStack(S); // 销毁栈
|
||||
}
|
||||
|
||||
|
||||
//算法5.8 创建二叉树
|
||||
template <class DT>
|
||||
void CreateBiTree(BTNode<DT>*& bt)
|
||||
{
|
||||
char ch;
|
||||
cin >> ch; // 输入根结点的数据
|
||||
if (ch == '#') // # 表示指针为空,说明树为空
|
||||
bt = NULL;
|
||||
else
|
||||
{
|
||||
bt = new BTNode<DT>; // 申请内存
|
||||
if (!bt)
|
||||
{
|
||||
cout << "申请内存失败!" << endl;
|
||||
exit(-1); // 申请内存失败退出
|
||||
}
|
||||
bt->data = ch;
|
||||
CreateBiTree(bt->lchild); // 创建根结点左子树
|
||||
CreateBiTree(bt->rchild); // 创建根结点右子树
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//算法5.9 销毁二叉树
|
||||
template <class DT>
|
||||
void DestroyBiTree(BTNode<DT>*& bt)
|
||||
{
|
||||
if (bt) // 树非空
|
||||
{
|
||||
DestroyBiTree(bt->lchild); // 销毁左子树
|
||||
DestroyBiTree(bt->rchild); // 销毁右子树
|
||||
delete bt;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//算法5.10 结点查找
|
||||
|
||||
template<class DT>
|
||||
BTNode<DT>* Search(BTNode<DT>* bt, DT e) // 查找值为e的元素
|
||||
{
|
||||
BTNode<DT>* p;
|
||||
if (bt == NULL) // 结点为空,返回
|
||||
return NULL;
|
||||
else if (bt->data == e) // 找到,返回结点指针
|
||||
return bt;
|
||||
else // 结点值不为e
|
||||
{
|
||||
p = Search(bt->lchild, e); // 在左子树上查找
|
||||
if (p != NULL) // 找到
|
||||
return p; // 返回结点指针
|
||||
else // 未找到
|
||||
return Search(bt->rchild, e); // 转右子树上查找
|
||||
}
|
||||
}
|
||||
|
||||
//算法5.11 求树深
|
||||
template <class DT>
|
||||
int Depth(BTNode<DT>* bt)
|
||||
{
|
||||
int hl, hr;
|
||||
if (bt == NULL) // 树空
|
||||
return 0; // 深度为0
|
||||
else // 树非空
|
||||
{
|
||||
|
||||
hl = Depth(bt->lchild); // 求左子树深度
|
||||
hr = Depth(bt->lchild); // 求右子树深度
|
||||
if (hl > hr) // 左子树高
|
||||
return hl + 1; // 树高为左子树高加1
|
||||
else return hr + 1; // 左子树高,树高为左子树高加1
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//算法5.12 结点计数
|
||||
template <class DT>
|
||||
int NodeCount(BTNode<DT>* bt)
|
||||
{
|
||||
if (bt == NULL) // 空树,结点数为0
|
||||
return 0;
|
||||
else // 非空树,结点数为左、右子树结点数的和加1
|
||||
return NodeCount(bt->lchild) + NodeCount(bt->rchild) + 1;
|
||||
}
|
||||
|
||||
template <class DT>
|
||||
void DispBiTree(BTNode<DT>* bt, int level) // 显示树
|
||||
{
|
||||
if (bt) //空二叉树不显示
|
||||
{
|
||||
DispBiTree(bt->rchild, level + 1); //显示右子树
|
||||
cout << endl; //显示新行
|
||||
for (int i = 0; i < level - 1; i++)
|
||||
cout << " "; //确保在第level列显示节点
|
||||
cout << bt->data; //显示节点
|
||||
DispBiTree(bt->lchild, level + 1); //显示左子树
|
||||
cout << endl;
|
||||
}//if
|
||||
}
|
||||
|
||||
|
||||
template <class DT>
|
||||
int leftCount(BTNode<DT>* bt)
|
||||
{
|
||||
if (bt->lchild == NULL && bt->rchild == NULL) // 空树,结点数为0
|
||||
return 0;
|
||||
else // 非空树,结点数为左、右子树结点数的和加1
|
||||
return NodeCount(bt->lchild) + NodeCount(bt->rchild) + 1;
|
||||
}
|
||||
|
||||
|
||||
//【算法3.14】 初始化队列
|
||||
template <class DT>
|
||||
void InitQueue(SqQueue<DT>& Q, int m)
|
||||
{
|
||||
Q.base = new BTNode<DT>*[m]; // 申请队列空间
|
||||
if (Q.base == NULL) // 申请空间失败
|
||||
{
|
||||
cout << "未创建成功!";
|
||||
exit(1); // 退出
|
||||
}
|
||||
Q.front = Q.rear = 0; // 设置队列属性
|
||||
Q.queuesize = m;
|
||||
}
|
||||
|
||||
|
||||
//算法3.15】 销毁列列
|
||||
template <class DT>
|
||||
void DestroyQueue(SqQueue<DT>& Q)
|
||||
{
|
||||
delete[] Q.base; // 释放队列空间
|
||||
Q.front = Q.rear = 0; // 设置队列属性
|
||||
Q.queuesize = 0;
|
||||
}
|
||||
|
||||
|
||||
//【算法3.16】 入队
|
||||
template<class DT>
|
||||
bool EnQueue(SqQueue<DT>& Q, BTNode<DT>* e)
|
||||
{
|
||||
if ((Q.rear + 1) % Q.queuesize == Q.front) // 队满
|
||||
return false; // 返回false
|
||||
Q.base[Q.rear] = e; // 出队
|
||||
Q.rear = (Q.rear + 1) % Q.queuesize; // 修改队列属性
|
||||
return true; // 返回true
|
||||
}
|
||||
|
||||
//【算法3.17】 出队
|
||||
template<class DT>
|
||||
bool DeQueue(SqQueue<DT>& Q, BTNode<DT>*& e)
|
||||
{
|
||||
if (Q.front == Q.rear) // 队空
|
||||
return false;
|
||||
e = Q.base[Q.front];
|
||||
Q.front = (Q.front + 1) % Q.queuesize;
|
||||
return true; // 删除成功,返回true
|
||||
}
|
||||
|
||||
// 测队空
|
||||
template<class DT>
|
||||
bool QueueEmpty(SqQueue<DT> Q)
|
||||
{
|
||||
if (Q.front == Q.rear) // 队空
|
||||
return true; // 返回true
|
||||
else // 队不空
|
||||
return false; // 返回false
|
||||
}
|
||||
|
||||
//【算法3.1】 初始化栈
|
||||
template <class DT>
|
||||
void InitStack(SqStack<DT>& S, int m)
|
||||
{
|
||||
S.base = new BTNode<DT>*[m]; // 申请栈空间
|
||||
if (S.base == NULL)
|
||||
{
|
||||
cout << "未创建成功!";
|
||||
exit(1);
|
||||
}
|
||||
S.top = -1; // 空栈
|
||||
S.stacksize = m; // 栈容量为m
|
||||
}
|
||||
|
||||
|
||||
//算法3.2】 销毁栈
|
||||
template <class DT>
|
||||
void DestroyStack(SqStack<DT>& S)//析构函数
|
||||
{
|
||||
delete[] S.base; //释放栈空间
|
||||
S.top = -1;
|
||||
S.stacksize = 0;
|
||||
}
|
||||
|
||||
|
||||
//【算法3.3】
|
||||
template<class DT>
|
||||
bool Push(SqStack<DT>& S, BTNode<DT>* e)
|
||||
{
|
||||
if (S.top == S.stacksize - 1) // 栈满,不能插入
|
||||
return false;
|
||||
S.top++;
|
||||
S.base[S.top] = e;
|
||||
return true; // 插入成功,返回true
|
||||
}
|
||||
|
||||
//【算法3.4】 出栈
|
||||
template<class DT>
|
||||
bool Pop(SqStack<DT>& S, BTNode<DT>*& e)
|
||||
{
|
||||
if (S.top == -1) //栈空
|
||||
return false;
|
||||
e = S.base[S.top];
|
||||
S.top--;
|
||||
return true; // 出栈成功,返回true
|
||||
}
|
||||
|
||||
template<class DT> // 获取栈元素
|
||||
bool GetTop(SqStack<DT>& S, BTNode<DT>*& e)
|
||||
{
|
||||
if (S.top == -1) // 栈空,返回false
|
||||
return false;
|
||||
e = S.base[S.top]; // 取栈元素
|
||||
return true; // 返回true
|
||||
}
|
||||
|
||||
|
||||
// 测栈空
|
||||
template<class DT>
|
||||
bool StackEmpty(SqStack<DT> S)
|
||||
{
|
||||
if (S.top == -1) // 栈空,返回true
|
||||
return true;
|
||||
else // 栈非空,返回false
|
||||
return false;
|
||||
}
|
||||
51
Chapter5/Chapter5.sln
Normal file
51
Chapter5/Chapter5.sln
Normal file
@@ -0,0 +1,51 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.9.34701.34
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BiTree", "BiTree\BiTree.vcxproj", "{904CFCDF-DA23-415A-8D68-8E51AD913458}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Huffmn", "Huffmn\Huffmn.vcxproj", "{A456A451-7570-4D79-9836-04559D3E944B}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ThrBiTree", "ThrBiTree\ThrBiTree.vcxproj", "{37EF98CA-2156-4ECB-A15D-52041DBAC78C}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{904CFCDF-DA23-415A-8D68-8E51AD913458}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{904CFCDF-DA23-415A-8D68-8E51AD913458}.Debug|x64.Build.0 = Debug|x64
|
||||
{904CFCDF-DA23-415A-8D68-8E51AD913458}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{904CFCDF-DA23-415A-8D68-8E51AD913458}.Debug|x86.Build.0 = Debug|Win32
|
||||
{904CFCDF-DA23-415A-8D68-8E51AD913458}.Release|x64.ActiveCfg = Release|x64
|
||||
{904CFCDF-DA23-415A-8D68-8E51AD913458}.Release|x64.Build.0 = Release|x64
|
||||
{904CFCDF-DA23-415A-8D68-8E51AD913458}.Release|x86.ActiveCfg = Release|Win32
|
||||
{904CFCDF-DA23-415A-8D68-8E51AD913458}.Release|x86.Build.0 = Release|Win32
|
||||
{A456A451-7570-4D79-9836-04559D3E944B}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{A456A451-7570-4D79-9836-04559D3E944B}.Debug|x64.Build.0 = Debug|x64
|
||||
{A456A451-7570-4D79-9836-04559D3E944B}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{A456A451-7570-4D79-9836-04559D3E944B}.Debug|x86.Build.0 = Debug|Win32
|
||||
{A456A451-7570-4D79-9836-04559D3E944B}.Release|x64.ActiveCfg = Release|x64
|
||||
{A456A451-7570-4D79-9836-04559D3E944B}.Release|x64.Build.0 = Release|x64
|
||||
{A456A451-7570-4D79-9836-04559D3E944B}.Release|x86.ActiveCfg = Release|Win32
|
||||
{A456A451-7570-4D79-9836-04559D3E944B}.Release|x86.Build.0 = Release|Win32
|
||||
{37EF98CA-2156-4ECB-A15D-52041DBAC78C}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{37EF98CA-2156-4ECB-A15D-52041DBAC78C}.Debug|x64.Build.0 = Debug|x64
|
||||
{37EF98CA-2156-4ECB-A15D-52041DBAC78C}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{37EF98CA-2156-4ECB-A15D-52041DBAC78C}.Debug|x86.Build.0 = Debug|Win32
|
||||
{37EF98CA-2156-4ECB-A15D-52041DBAC78C}.Release|x64.ActiveCfg = Release|x64
|
||||
{37EF98CA-2156-4ECB-A15D-52041DBAC78C}.Release|x64.Build.0 = Release|x64
|
||||
{37EF98CA-2156-4ECB-A15D-52041DBAC78C}.Release|x86.ActiveCfg = Release|Win32
|
||||
{37EF98CA-2156-4ECB-A15D-52041DBAC78C}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {9F80D9BF-39B0-44C0-A084-A3293924BB63}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
137
Chapter5/Huffmn/Huffmn.vcxproj
Normal file
137
Chapter5/Huffmn/Huffmn.vcxproj
Normal file
@@ -0,0 +1,137 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>17.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{a456a451-7570-4d79-9836-04559d3e944b}</ProjectGuid>
|
||||
<RootNamespace>Huffmn</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="HumanTree.cpp">
|
||||
<SDLCheck Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</SDLCheck>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
22
Chapter5/Huffmn/Huffmn.vcxproj.filters
Normal file
22
Chapter5/Huffmn/Huffmn.vcxproj.filters
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="源文件">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="头文件">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="资源文件">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="HumanTree.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
165
Chapter5/Huffmn/HumanTree.cpp
Normal file
165
Chapter5/Huffmn/HumanTree.cpp
Normal file
@@ -0,0 +1,165 @@
|
||||
#include"iostream"
|
||||
#include<iomanip>
|
||||
#include<string>
|
||||
using namespace std;
|
||||
|
||||
struct HTNode
|
||||
{
|
||||
int weight; // 权值,设为整型
|
||||
int parent; // 双亲位置
|
||||
int lchild; // 左孩子位置
|
||||
int rchild; // 右孩子位置
|
||||
};
|
||||
|
||||
|
||||
void select(HTNode* HT, int k, int& i1, int& i2) // 在前K-1个结点中选择权值最小的两个根结点i和j
|
||||
{
|
||||
int m1, m2;
|
||||
m1 = m2 = 32767; //
|
||||
i1 = i2 = 0;
|
||||
for (int j = 0; j < k; j++)
|
||||
{
|
||||
if (HT[j].weight < m1 && HT[j].parent == -1)
|
||||
{
|
||||
m2 = m1, i2 = i1;
|
||||
m1 = HT[j].weight;
|
||||
i1 = j;
|
||||
}
|
||||
else if (HT[j].weight < m2 && HT[j].parent == -1)
|
||||
{
|
||||
m2 = HT[j].weight;
|
||||
i2 = j;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 算法5.16 // 构造哈夫曼树
|
||||
void HuffmanTree(HTNode*& HT, int* w, int n)
|
||||
{ // n是叶子结点的个数,w是叶子结点的权值数组
|
||||
HTNode* p;
|
||||
int k, i;
|
||||
int i1, i2;
|
||||
p = HT;
|
||||
for (i = 0; i < 2 * n - 1; i++)
|
||||
{ // 设置初始状态,所有结点的指针为空
|
||||
HT[i].weight = 0;
|
||||
HT[i].parent = -1;
|
||||
HT[i].lchild = -1;
|
||||
HT[i].rchild = -1;
|
||||
}
|
||||
for (i = 0; i < n; i++)
|
||||
{ // 前n个结点的权值分别为个结点的权值
|
||||
HT[i].weight = w[i];
|
||||
}
|
||||
for (k = n; k < 2 * n - 1; k++)
|
||||
{ // 构造最优二叉树
|
||||
select(HT, k, i1, i2); // 在前K-1个结点中选择权值最小的两个根结点i1和i2
|
||||
HT[i1].parent = k;
|
||||
HT[i2].parent = k;
|
||||
HT[k].weight = HT[i1].weight + HT[i2].weight;
|
||||
HT[k].lchild = i1;
|
||||
HT[k].rchild = i2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DispHT(HTNode* HT, int n) // 显示哈夫曼树存储
|
||||
{
|
||||
HTNode* p;
|
||||
p = HT;
|
||||
cout << "k" << setw(7) << "Weight" << setw(7) << "parent"
|
||||
<< setw(7) << "lchild" << setw(7) << "rchild" << endl;
|
||||
for (int k = 0; k < 2 * n - 1; k++)
|
||||
{
|
||||
cout << k << setw(7) << (p + k)->weight << setw(7) << (p + k)->parent
|
||||
<< setw(7) << (p + k)->lchild << setw(7) << (p + k)->rchild << endl;
|
||||
}
|
||||
}
|
||||
|
||||
//算法5.17 // 构建哈夫曼编码
|
||||
void CreateHFCode(HTNode* HT, int n, char** HC)
|
||||
{
|
||||
int i, start, c, f;
|
||||
char* cd;
|
||||
cd = new char[n];
|
||||
cd[n - 1] = '\0';
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
start = n - 1;
|
||||
c = i;
|
||||
f = HT[i].parent;
|
||||
while (f != -1)
|
||||
{
|
||||
if (HT[f].lchild == c)
|
||||
cd[--start] = '0';
|
||||
else
|
||||
cd[--start] = '1';
|
||||
c = f; f = HT[f].parent;
|
||||
}
|
||||
cout << endl;
|
||||
HC[i] = new char[n - start];
|
||||
HC[i] = &cd[start];
|
||||
int j = 0;
|
||||
while (HC[i][j] != '\0') // 显示编码
|
||||
{
|
||||
cout << HC[i][j];
|
||||
j++;
|
||||
}
|
||||
|
||||
}
|
||||
delete cd;
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
|
||||
int op;
|
||||
|
||||
int main()
|
||||
{
|
||||
int* w; // 权值数组
|
||||
int n; // 权值个数
|
||||
int i; // 工作变量
|
||||
HTNode* HT; // 哈夫曼树
|
||||
char** HC;
|
||||
do
|
||||
{
|
||||
cout << "1-输入结点权值" << endl;
|
||||
cout << "2-生成最优二叉树" << endl;
|
||||
cout << "3-求哈夫曼编码" << endl;
|
||||
cout << "4-退出程序" << endl;
|
||||
cout << "请选择操作(1~4):";
|
||||
cout << "\b\b";
|
||||
cin >> op;
|
||||
switch (op)
|
||||
{
|
||||
case 1:
|
||||
cout << "测试案例" << endl;
|
||||
cout << "7,5,2,3,5,6" << endl;
|
||||
cout << "请输入结点的个数:";
|
||||
cin >> n;
|
||||
w = new int[n];
|
||||
cout << "请依次输入权值:" << endl;
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
cout << "请输入第" << i + 1 << "个权值:";
|
||||
cin >> w[i];
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
HT = new HTNode[2 * n - 1]; // 申请最优二叉树存储空间
|
||||
HuffmanTree(HT, w, n);
|
||||
cout << "创建的哈夫曼树为:\n";
|
||||
DispHT(HT, n);
|
||||
system("pause");
|
||||
break;
|
||||
case 3:
|
||||
HC = new char* [n]; // 存储哈示曼编码
|
||||
cout << "哈夫曼编码为:\n";
|
||||
CreateHFCode(HT, n, HC);
|
||||
break;
|
||||
case 4:
|
||||
cout << "结束运行,Bye-Bye!" << endl;
|
||||
break;
|
||||
}
|
||||
} while (op != 4);
|
||||
return 0;
|
||||
}
|
||||
222
Chapter5/ThrBiTree/ThrBiTree.cpp
Normal file
222
Chapter5/ThrBiTree/ThrBiTree.cpp
Normal file
@@ -0,0 +1,222 @@
|
||||
#include<iostream>//cout,cin
|
||||
#include<string>
|
||||
using namespace std;
|
||||
|
||||
template<class DT>
|
||||
struct ThrBTNode
|
||||
{
|
||||
DT data; // 数据域
|
||||
int lflag; // 左标志域
|
||||
int rflag; // 右标志域
|
||||
ThrBTNode* lchild; // 左指针域
|
||||
ThrBTNode* rchild; // 右指针域
|
||||
};
|
||||
|
||||
|
||||
template <class DT> // 创建二叉树
|
||||
void CreateBiTree(ThrBTNode<DT>*& bt)
|
||||
{ // 按先序序列的顺序输入二叉树,#为空指针域标志;
|
||||
char ch;
|
||||
cin >> ch; // 输入根结点的数据
|
||||
if (ch == '#') // # 表示指针为空,说明树为空
|
||||
bt = NULL;
|
||||
else
|
||||
{
|
||||
bt = new ThrBTNode<DT>; // 新建结点
|
||||
if (!bt)
|
||||
{
|
||||
cout << "申请内存失败!" << endl;
|
||||
exit(-1); // 申请内存失败退出
|
||||
}
|
||||
bt->lflag = 0; // 非线索
|
||||
bt->rflag = 0; // 非线索
|
||||
bt->data = ch;
|
||||
CreateBiTree(bt->lchild); // 递归创建根结点左子树
|
||||
CreateBiTree(bt->rchild); // 递归创建根结点右子树
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
ThrBTNode<char>* pre;
|
||||
|
||||
//算法5.13 中序线索化二叉树
|
||||
template <class DT>
|
||||
void InThread(ThrBTNode<DT>*& p)
|
||||
{
|
||||
|
||||
if (p != NULL) // 结点非空
|
||||
{
|
||||
InThread(p->lchild); // 中序线索化左子树
|
||||
if (p->lchild == NULL) // 结点无左孩子
|
||||
{
|
||||
p->lflag = 1; // 设置前驱线索标识
|
||||
p->lchild = pre; // 左孩子指向结点遍历前驱
|
||||
}
|
||||
if (pre->rchild == NULL) // 结点无右孩子
|
||||
{
|
||||
pre->rflag = 1; // 设置后继线索标识
|
||||
pre->rchild = p; // 右孩子指向结点遍历后继
|
||||
}
|
||||
pre = p; // 前驱指向当前结点
|
||||
InThread(p->rchild); // 中序线索化右子树
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class DT> // 构建线索二叉树
|
||||
ThrBTNode<DT>* CreateInThread(ThrBTNode<DT>*& bt)
|
||||
{
|
||||
ThrBTNode<DT>* root;
|
||||
root = new ThrBTNode<DT>; // 创建头结点
|
||||
root->lflag = 0;
|
||||
root->rflag = 1;
|
||||
root->rchild = bt;
|
||||
if (bt == NULL)
|
||||
root->lchild = root;
|
||||
else
|
||||
{
|
||||
root->lchild = bt;
|
||||
pre = root;
|
||||
InThread(bt); // 中序线索化二叉树
|
||||
pre->rchild = root; // 设置循环链表
|
||||
pre->rflag = 1;
|
||||
root->rchild = pre;
|
||||
}
|
||||
return root;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//算法5.15 中序遍历中序线索二叉树
|
||||
template<class DT>
|
||||
void InThrBiTree(ThrBTNode<DT>* bt)
|
||||
{
|
||||
ThrBTNode<DT>* p;
|
||||
p = bt->lchild; // 从根结点开始
|
||||
while (p != bt) // 结点非空
|
||||
{
|
||||
while (p->lflag == 0) // 有左孩子
|
||||
p = p->lchild; // 一路左行
|
||||
cout << p->data; // 访问结点
|
||||
while (p->rflag == 1 && p->rchild != bt) // 有后继线索且非空
|
||||
{
|
||||
p = p->rchild; // 转向后继
|
||||
cout << p->data << " "; // 访问后继结点
|
||||
}
|
||||
p = p->rchild; // 无后继线索,转向右子树
|
||||
}
|
||||
}
|
||||
|
||||
template <class DT> // 显示线索二叉树
|
||||
void DispBiTree(ThrBTNode<DT>* bt, int level)
|
||||
{
|
||||
if (bt) // 空二叉树不显示
|
||||
{
|
||||
DispBiTree(bt->rchild, level + 1); // 显示右子树
|
||||
cout << endl; // 显示新行
|
||||
for (int i = 0; i < level - 1; i++)
|
||||
cout << " "; // 确保在第level列显示节点
|
||||
cout << bt->data; // 显示节点
|
||||
DispBiTree(bt->lchild, level + 1); // 显示左子树
|
||||
cout << endl;
|
||||
}//if
|
||||
}//DisplayBTree
|
||||
|
||||
//算法5.9 销毁二叉树
|
||||
template <class DT>
|
||||
void DestroyThrBiTree(ThrBTNode<DT>*& bt)
|
||||
{
|
||||
if (bt)
|
||||
{
|
||||
DestroyThrBiTree(bt->lchild);
|
||||
DestroyThrBiTree(bt->rchild);
|
||||
delete bt;
|
||||
}
|
||||
}
|
||||
|
||||
void dispmenu()
|
||||
{ // 显示主菜单
|
||||
cout << endl;
|
||||
cout << "1-创建二叉树\n";
|
||||
//cout<<"2-先序线索化二叉树的先序遍历\n";
|
||||
//cout<<"3-先序遍历先序线索化二叉树\n";
|
||||
cout << "4-中序线索化二叉树\n";
|
||||
cout << "5-中序遍历中序线索二叉树\n";
|
||||
cout << "6-显示二叉树\n";
|
||||
cout << "7-退出\n";
|
||||
}
|
||||
|
||||
// 测试数据
|
||||
string fbt = "a b d # # e # # c f # # g # #"; // 满二叉树最后一层每个叶结点后有两个#
|
||||
string cbt = "a b d # # e # # c # #"; // 完全二叉树每个叶结点后有两个#
|
||||
string gbt = "a b # d # # c e # # #"; // 一般二叉树
|
||||
string obt = "a b c d # # # # #"; // 左斜树
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
//char pause;
|
||||
int level;
|
||||
ThrBTNode<char>* bt;
|
||||
|
||||
|
||||
system("cls"); // 清屏
|
||||
|
||||
int choice;
|
||||
do
|
||||
{
|
||||
dispmenu(); //显示主菜单
|
||||
cout << "Enter choice(1~7):";
|
||||
cin >> choice;
|
||||
switch (choice)
|
||||
{
|
||||
case 1: //创建二叉树
|
||||
cout << "测试数据参考:" << endl;
|
||||
cout << "满二叉树:" << fbt << endl;
|
||||
cout << "完全二叉树:" << cbt << endl;
|
||||
cout << "一般二叉树:" << gbt << endl;
|
||||
cout << "左斜二叉树:" << obt << endl;
|
||||
cout << "请按先序序列的顺序输入二叉树,#为空指针域标志:" << endl;
|
||||
CreateBiTree(bt);
|
||||
break;
|
||||
case 2://先序线索化二叉树
|
||||
|
||||
//PreThread(bt);
|
||||
//cin.get(pause);
|
||||
//system("pause");
|
||||
break;
|
||||
case 3://先序遍历先线索化二叉树
|
||||
|
||||
//PreOrDerBiTree(bt);
|
||||
//cin.get(pause);
|
||||
//system("pause");
|
||||
//breCreateInThread(bt);
|
||||
case 4: //中序线索化二叉树
|
||||
bt = CreateInThread(bt);
|
||||
cout << "中序线索化成功!";
|
||||
cout << endl;
|
||||
break;
|
||||
case 5: //中序遍历中序线索二叉树
|
||||
cout << "中序遍历序列为:" << endl;
|
||||
cout << endl;
|
||||
InThrBiTree(bt);
|
||||
break;
|
||||
case 6: //显示二叉树
|
||||
cout << "2-显示二叉树" << endl;
|
||||
level = 1;
|
||||
DispBiTree(bt, level);
|
||||
cout << endl;
|
||||
break;
|
||||
case 7://退出
|
||||
cout << "结束运行!" << endl;
|
||||
DestroyThrBiTree(bt);
|
||||
break;
|
||||
default://非法选择
|
||||
cout << "Invalid choice\n";
|
||||
break;
|
||||
}
|
||||
} while (choice != 7);
|
||||
|
||||
return 0;
|
||||
}
|
||||
135
Chapter5/ThrBiTree/ThrBiTree.vcxproj
Normal file
135
Chapter5/ThrBiTree/ThrBiTree.vcxproj
Normal file
@@ -0,0 +1,135 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>17.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{37ef98ca-2156-4ecb-a15d-52041dbac78c}</ProjectGuid>
|
||||
<RootNamespace>ThrBiTree</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>false</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="ThrBiTree.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
22
Chapter5/ThrBiTree/ThrBiTree.vcxproj.filters
Normal file
22
Chapter5/ThrBiTree/ThrBiTree.vcxproj.filters
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="源文件">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="头文件">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="资源文件">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="ThrBiTree.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user