資源簡介
這是一個將項目制作成dll的參考工程,關(guān)于細節(jié)方面,請轉(zhuǎn)到我的博客詳細參考,謝謝
代碼片段和文件信息
#include?
#include?
#include?“..\Utilities\BinaryTree.h“
using?namespace?std;
BinaryTreeNode*?ConstructCore(int*?startPreorder?int*?endPreorder?int*?startInorder?int*?endInorder);
BinaryTreeNode*?Construct(int*?preorder?int*?inorder?int?length)
{
if?(preorder?==?NULL?||?inorder?==?NULL?||?length?<=?0)
return?NULL;
return?ConstructCore(preorder?preorder?+?length?-?1
inorder?inorder?+?length?-?1);
}
BinaryTreeNode*?ConstructCore(int*?startPreorder?int*?endPreorder
??int*?startInorder?int*?endInorder)
{
int?rootValue?=?startPreorder[0];
BinaryTreeNode*?root?=?new?BinaryTreeNode();
root->m_nValue?=?rootValue;
root->m_pLeft?=?root->m_pRight?=?NULL;
if?(startPreorder?==?endPreorder)?{
if?(startInorder?==?endInorder?&&?*startPreorder?==?*startInorder)
return?root;
else
throw?exception(“Invalid?Input“);
}
//在中序遍歷中找到根節(jié)點的值
//cout?<<“*startInorder“?<<*startInorder?< int*?rootInorder?=?startInorder;
while?(rootInorder?<=?endInorder?&&?*rootInorder?!=?rootValue)
++rootInorder;
if?(rootInorder?==?endInorder?&&?*rootInorder?!=?rootValue)
throw?exception(“Invalid?Input“);
int?leftLength?=?rootInorder?-?startInorder;
int*?leftPreorderEnd?=?startPreorder?+?leftLength;
if?(leftLength?>?0)
root->m_pLeft?=?ConstructCore(startPreorder?+?1?leftPreorderEnd
startInorder?rootInorder?-?1);
if?(leftLength? root->m_pRight?=?ConstructCore(leftPreorderEnd?+?1?endPreorder
rootInorder?+?1?endInorder);
return?root;
}
int?main()
{
const?int?length?=?8;
int?preOrderArray[length]?=?{?12473568?};
int?inOrderArray[length]?=?{?47215386?};
BinaryTreeNode*?root?=?Construct(preOrderArray?inOrderArray?length);
//PrintPreOrder(root);
PrintTree(root);
DestroyTree(root);
int?a;
cin?>>?a;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2015-12-29?17:03??MyInterviewQuestion\
?????目錄???????????0??2015-12-28?16:31??MyInterviewQuestion\.vs\
?????目錄???????????0??2015-12-28?16:31??MyInterviewQuestion\.vs\MyInterviewQuestion\
?????目錄???????????0??2015-12-28?16:31??MyInterviewQuestion\.vs\MyInterviewQuestion\v14\
?????文件???????92160??2015-12-29?17:03??MyInterviewQuestion\.vs\MyInterviewQuestion\v14\.suo
?????目錄???????????0??2015-12-29?15:16??MyInterviewQuestion\ConstructBinaryTree\
?????文件????????6226??2015-12-29?16:31??MyInterviewQuestion\ConstructBinaryTree\ConstructBinaryTree.vcxproj
?????文件?????????959??2015-12-28?23:07??MyInterviewQuestion\ConstructBinaryTree\ConstructBinaryTree.vcxproj.filters
?????文件????????1912??2015-12-29?15:16??MyInterviewQuestion\ConstructBinaryTree\construtbinarytree.cpp
?????目錄???????????0??2015-12-29?16:31??MyInterviewQuestion\ConstructBinaryTree\Debug\
?????目錄???????????0??2015-12-29?16:31??MyInterviewQuestion\ConstructBinaryTree\Debug\Construc.C696DF69.tlog\
?????文件?????????708??2015-12-29?16:24??MyInterviewQuestion\ConstructBinaryTree\Debug\Construc.C696DF69.tlog\CL.command.1.tlog
?????文件???????12440??2015-12-29?16:24??MyInterviewQuestion\ConstructBinaryTree\Debug\Construc.C696DF69.tlog\CL.read.1.tlog
?????文件?????????708??2015-12-29?16:24??MyInterviewQuestion\ConstructBinaryTree\Debug\Construc.C696DF69.tlog\CL.write.1.tlog
?????文件?????????179??2015-12-29?16:31??MyInterviewQuestion\ConstructBinaryTree\Debug\Construc.C696DF69.tlog\ConstructBinaryTree.lastbuildstate
?????文件????????1606??2015-12-29?16:31??MyInterviewQuestion\ConstructBinaryTree\Debug\Construc.C696DF69.tlog\li
?????文件????????3280??2015-12-29?16:31??MyInterviewQuestion\ConstructBinaryTree\Debug\Construc.C696DF69.tlog\li
?????文件?????????790??2015-12-29?16:31??MyInterviewQuestion\ConstructBinaryTree\Debug\Construc.C696DF69.tlog\li
?????文件????????1259??2015-12-29?16:31??MyInterviewQuestion\ConstructBinaryTree\Debug\ConstructBinaryTree.log
?????文件?????????671??2015-12-29?16:31??MyInterviewQuestion\ConstructBinaryTree\Debug\ConstructBinaryTree.vcxprojResolveAssemblyReference.cache
?????文件???????29604??2015-12-29?16:24??MyInterviewQuestion\ConstructBinaryTree\Debug\construtbinarytree.obj
?????文件??????322560??2015-12-29?16:24??MyInterviewQuestion\ConstructBinaryTree\Debug\vc140.idb
?????文件??????356352??2015-12-29?16:24??MyInterviewQuestion\ConstructBinaryTree\Debug\vc140.pdb
?????目錄???????????0??2015-12-29?16:31??MyInterviewQuestion\Debug\
?????文件???????40960??2015-12-29?16:31??MyInterviewQuestion\Debug\ConstructBinaryTree.exe
?????文件??????328340??2015-12-29?16:31??MyInterviewQuestion\Debug\ConstructBinaryTree.ilk
?????文件??????913408??2015-12-29?16:31??MyInterviewQuestion\Debug\ConstructBinaryTree.pdb
?????文件???????36352??2015-12-29?16:37??MyInterviewQuestion\Debug\Utilities.dll
?????文件????????1142??2015-12-29?16:29??MyInterviewQuestion\Debug\Utilities.exp
?????文件??????250564??2015-12-29?16:37??MyInterviewQuestion\Debug\Utilities.ilk
?????文件????????2504??2015-12-29?16:29??MyInterviewQuestion\Debug\Utilities.lib
............此處省略32個文件信息
評論
共有 條評論