| @@ -117,3 +117,4 @@ Alogrithm/.vs/Alogrithm/v16/ipch/AutoPCH/d00489e06883ba57/9_ ADDBINARY.ipch | |||||
| Alogrithm/TestResults/dc42f77d-a2f7-41a9-8b8c-1ee3f1a82eb9/林_MI-1 2021-01-18 14_12_23.coverage | Alogrithm/TestResults/dc42f77d-a2f7-41a9-8b8c-1ee3f1a82eb9/林_MI-1 2021-01-18 14_12_23.coverage | ||||
| Alogrithm/.vs/Alogrithm/v16/ipch/AutoPCH/86fa7a487ad3f37c/10_BINARYTREEPATHS.ipch | Alogrithm/.vs/Alogrithm/v16/ipch/AutoPCH/86fa7a487ad3f37c/10_BINARYTREEPATHS.ipch | ||||
| Alogrithm/Alogrithm/Debug/10_BinaryTreePaths.obj | Alogrithm/Alogrithm/Debug/10_BinaryTreePaths.obj | ||||
| Alogrithm/.vs/Alogrithm/v16/TestStore/3/003.testlog | |||||
| @@ -0,0 +1,19 @@ | |||||
| [Test1] | |||||
| Input=1,2,3,NULL,5 | |||||
| Output=1->2->5,1->3 | |||||
| [Test2] | |||||
| Input=1,2,3,NULL,4,5 | |||||
| Output=1->2->4,1->3->5 | |||||
| [Test3] | |||||
| input=1,0,0,2,NULL,NULL,0 | |||||
| output=1->0->2,1->0->0 | |||||
| [Test4] | |||||
| input= | |||||
| output= | |||||
| [Test5] | |||||
| input=4,3,1,NULL,2,6,8 | |||||
| output=4->3->2,4->1->6,4->1->8 | |||||
| [Test6] | |||||
| input=1,3,5,7,NULL,2,9,NULL,2 | |||||
| output=1->3->7->2,1->5->2,1->5->9 | |||||
| @@ -1,4 +1,5 @@ | |||||
| #pragma once | |||||
| #include <atlstr.h> | |||||
| struct TreeNode3 | struct TreeNode3 | ||||
| { | { | ||||
| @@ -7,12 +8,10 @@ struct TreeNode3 | |||||
| struct TreeNode3* right; | struct TreeNode3* right; | ||||
| }; | }; | ||||
| #pragma once | |||||
| #include <atlstr.h> | |||||
| void CreatBitTreeNode3(char str[][50], int return_count, TreeNode3* cur, int curIndex); | void CreatBitTreeNode3(char str[][50], int return_count, TreeNode3* cur, int curIndex); | ||||
| TreeNode3* CreatBitTree3(char str[][50], int return_count); | TreeNode3* CreatBitTree3(char str[][50], int return_count); | ||||
| void get_path(char** array, struct TreeNode3* root, int* returnSize, int* buf, int local); | void get_path(char** array, struct TreeNode3* root, int* returnSize, int* buf, int local); | ||||
| char** binaryTreePaths(struct TreeNode3* root, int* returnSize); | char** binaryTreePaths(struct TreeNode3* root, int* returnSize); | ||||
| void free_tree3(TreeNode3* T); | void free_tree3(TreeNode3* T); | ||||
| int str_device2(CString str, char(*return_str)[50]); | |||||
| @@ -87,20 +87,3 @@ void free_tree3(TreeNode3* T)// | |||||
| T = NULL; | T = NULL; | ||||
| } | } | ||||
| } | } | ||||
| int str_device2(CString str, char(*return_str)[50]) | |||||
| { | |||||
| int value_count = 0; | |||||
| char* token; //存放被切割后的第一个子串 | |||||
| char Section_value[500] = { 0 };//存放nums转换成string类型的结果 | |||||
| memset(Section_value, 0, sizeof(char) * 500); | |||||
| strcpy(Section_value, str);//将CString类型的字符串转换成char类型,方便后面切割字符串 | |||||
| //获得切割到的第一个字符串 | |||||
| token = strtok(Section_value, ","); | |||||
| /* 继续获取其他的子字符串 */ | |||||
| while (token != NULL) { | |||||
| strcpy(return_str[value_count], token); | |||||
| token = strtok(NULL, ","); | |||||
| value_count++; //记录存了多少个元素 | |||||
| } | |||||
| return value_count; //返回数组首地址 | |||||
| } | |||||
| @@ -1,33 +1,8 @@ | |||||
| #include "../include/10_BinaryTreePaths.h" | |||||
| int main() | int main() | ||||
| { | { | ||||
| CString str = "3,9,20,NULL,NULL,15,17"; | |||||
| CString str1 = "4,3,1,NULL,NULL,2,6,8"; | |||||
| char return_str[100][50] = { 0 }; | |||||
| int return_count = str_device2(str, return_str); | |||||
| TreeNode3* root = CreatBitTree3(return_str, return_count); | |||||
| int returnSize = 0; | |||||
| char** returnStr; | |||||
| char s[1024] = {0}; | |||||
| char *q = "123"; | |||||
| char* p = "123"; | |||||
| returnStr = binaryTreePaths(root, &returnSize); | |||||
| for (int i = 0; i < returnSize; i++) | |||||
| { | |||||
| //sprintf(s, "%s", returnStr[i]); | |||||
| strcat(s, returnStr[i]); | |||||
| if (i != (returnSize-1)) | |||||
| { | |||||
| s[strlen(s)] = ','; | |||||
| } | |||||
| } | |||||
| printf("%s\n", s); | |||||
| free_tree3(root); | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| @@ -11,6 +11,7 @@ using namespace Microsoft::VisualStudio::CppUnitTestFramework; | |||||
| #define FileName_7 "../Alogrithm/config/7_MaxDepth.ini" | #define FileName_7 "../Alogrithm/config/7_MaxDepth.ini" | ||||
| #define FileName_8 "../Alogrithm/config/8_HammingWeight.ini" | #define FileName_8 "../Alogrithm/config/8_HammingWeight.ini" | ||||
| #define FileName_9 "../Alogrithm/config/9_AddBinary.ini" | #define FileName_9 "../Alogrithm/config/9_AddBinary.ini" | ||||
| #define FileName_10 "../Alogrithm/config/10_BinaryTreePaths.ini" | |||||
| namespace UnitTest | namespace UnitTest | ||||
| @@ -170,4 +171,35 @@ namespace UnitTest | |||||
| } | } | ||||
| } | } | ||||
| }; | }; | ||||
| TEST_CLASS(UnitTest_10) | |||||
| { | |||||
| TEST_METHOD(TestMethode1) | |||||
| { | |||||
| char Section_Name[100][10] = { 0 }; | |||||
| int Section_Count = CalcCount(100, Section_Name, FileName_10); | |||||
| CString Na, nExpect; | |||||
| for (int i = 0; i < Section_Count; i++) { | |||||
| GetPrivateProfileString(Section_Name[i], "input", " ", Na.GetBuffer(200), 200, FileName_10); | |||||
| GetPrivateProfileString(Section_Name[i], "output", " ", nExpect.GetBuffer(500), 500, FileName_10); | |||||
| char return_str[100][50] = { 0 }; | |||||
| int return_count = str_device2(Na, return_str); | |||||
| TreeNode3* root = CreatBitTree3(return_str, return_count); | |||||
| int returnSize = 0; | |||||
| char** returnStr=NULL; | |||||
| returnStr = binaryTreePaths(root, &returnSize); | |||||
| char nReal[500] = { 0 }; | |||||
| for (int i = 0; i < returnSize; i++) | |||||
| { | |||||
| strcat(nReal, returnStr[i]); | |||||
| if (i != (returnSize - 1)) | |||||
| { | |||||
| nReal[strlen(nReal)] = ','; | |||||
| } | |||||
| } | |||||
| Assert::AreEqual(nReal,nExpect); | |||||
| free_tree3(root); | |||||
| } | |||||
| } | |||||
| }; | |||||
| } | } | ||||
| @@ -103,7 +103,7 @@ | |||||
| <SubSystem>Windows</SubSystem> | <SubSystem>Windows</SubSystem> | ||||
| <AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> | <AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> | ||||
| <GenerateDebugInformation>DebugFull</GenerateDebugInformation> | <GenerateDebugInformation>DebugFull</GenerateDebugInformation> | ||||
| <AdditionalDependencies>../Alogrithm/Debug/1_ContainsNearbyDuplicate.obj;../Alogrithm/Debug/2_ExcelSheetColumnTitle.obj;../Alogrithm/Debug/3_bool IsUgly.obj;../Alogrithm/Debug/4_IsPalindrome.obj;../Alogrithm/Debug/5_MinDepth.obj;../Alogrithm/Debug/6_ContainsDuplicate.obj;../Alogrithm/Debug/7_MaxDepth.obj;../Alogrithm/Debug/8_HammingWeight.obj;../Alogrithm/Debug/9_AddBinary.obj;%(AdditionalDependencies)</AdditionalDependencies> | |||||
| <AdditionalDependencies>../Alogrithm/Debug/1_ContainsNearbyDuplicate.obj;../Alogrithm/Debug/2_ExcelSheetColumnTitle.obj;../Alogrithm/Debug/3_bool IsUgly.obj;../Alogrithm/Debug/4_IsPalindrome.obj;../Alogrithm/Debug/5_MinDepth.obj;../Alogrithm/Debug/6_ContainsDuplicate.obj;../Alogrithm/Debug/7_MaxDepth.obj;../Alogrithm/Debug/8_HammingWeight.obj;../Alogrithm/Debug/9_AddBinary.obj;../Alogrithm/Debug/10_BinaryTreePaths.obj;%(AdditionalDependencies)</AdditionalDependencies> | |||||
| </Link> | </Link> | ||||
| </ItemDefinitionGroup> | </ItemDefinitionGroup> | ||||
| <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||||
| @@ -22,6 +22,7 @@ | |||||
| #include"../Alogrithm/include/7_MaxDepth.h" | #include"../Alogrithm/include/7_MaxDepth.h" | ||||
| #include"../Alogrithm/include/8_HammingWeight.h" | #include"../Alogrithm/include/8_HammingWeight.h" | ||||
| #include"../Alogrithm/include/9_AddBinary.h" | #include"../Alogrithm/include/9_AddBinary.h" | ||||
| #include"../Alogrithm/include/10_BinaryTreePaths.h" | |||||
| int CalcCount(int n, char(*str)[10],const char *FileName); | int CalcCount(int n, char(*str)[10],const char *FileName); | ||||