diff --git a/.gitignore b/.gitignore
index 04fb84c..afc2ddc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -115,3 +115,5 @@ Alogrithm/Alogrithm/Debug/9_AddBinary.obj
Alogrithm/.vs/Alogrithm/v16/ipch/AutoPCH/27a527fda8b54c6b/9_ADDBINARY.ipch
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/.vs/Alogrithm/v16/ipch/AutoPCH/86fa7a487ad3f37c/10_BINARYTREEPATHS.ipch
+Alogrithm/Alogrithm/Debug/10_BinaryTreePaths.obj
diff --git a/Alogrithm/.vs/Alogrithm/v16/.suo b/Alogrithm/.vs/Alogrithm/v16/.suo
index 9014215..e2c7770 100644
Binary files a/Alogrithm/.vs/Alogrithm/v16/.suo and b/Alogrithm/.vs/Alogrithm/v16/.suo differ
diff --git a/Alogrithm/Alogrithm/Alogrithm.vcxproj b/Alogrithm/Alogrithm/Alogrithm.vcxproj
index 847bf41..28181ae 100644
--- a/Alogrithm/Alogrithm/Alogrithm.vcxproj
+++ b/Alogrithm/Alogrithm/Alogrithm.vcxproj
@@ -86,8 +86,8 @@
Level3
true
- WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
+ WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
+ false
Console
@@ -140,6 +140,7 @@
+
@@ -152,6 +153,7 @@
+
@@ -163,6 +165,7 @@
+
diff --git a/Alogrithm/Alogrithm/Alogrithm.vcxproj.filters b/Alogrithm/Alogrithm/Alogrithm.vcxproj.filters
index 61f2f35..4857c43 100644
--- a/Alogrithm/Alogrithm/Alogrithm.vcxproj.filters
+++ b/Alogrithm/Alogrithm/Alogrithm.vcxproj.filters
@@ -54,6 +54,9 @@
源文件\src
+
+ 源文件\src
+
@@ -83,6 +86,9 @@
头文件\include
+
+ 头文件
+
@@ -112,5 +118,8 @@
资源文件\config
+
+ 资源文件\config
+
\ No newline at end of file
diff --git a/Alogrithm/Alogrithm/config/10_BinaryTreePaths.ini b/Alogrithm/Alogrithm/config/10_BinaryTreePaths.ini
new file mode 100644
index 0000000..e69de29
diff --git a/Alogrithm/Alogrithm/include/10_BinaryTreePaths.h b/Alogrithm/Alogrithm/include/10_BinaryTreePaths.h
new file mode 100644
index 0000000..89f3350
--- /dev/null
+++ b/Alogrithm/Alogrithm/include/10_BinaryTreePaths.h
@@ -0,0 +1,18 @@
+
+
+struct TreeNode3
+{
+ int val;
+ struct TreeNode3* left;
+ struct TreeNode3* right;
+};
+
+#pragma once
+#include
+
+void CreatBitTreeNode3(char str[][50], int return_count, TreeNode3* cur, int curIndex);
+TreeNode3* CreatBitTree3(char str[][50], int return_count);
+void get_path(char** array, struct TreeNode3* root, int* returnSize, int* buf, int local);
+char** binaryTreePaths(struct TreeNode3* root, int* returnSize);
+void free_tree3(TreeNode3* T);
+int str_device2(CString str, char(*return_str)[50]);
\ No newline at end of file
diff --git a/Alogrithm/Alogrithm/src/10_BinaryTreePaths.cpp b/Alogrithm/Alogrithm/src/10_BinaryTreePaths.cpp
new file mode 100644
index 0000000..ce1918f
--- /dev/null
+++ b/Alogrithm/Alogrithm/src/10_BinaryTreePaths.cpp
@@ -0,0 +1,106 @@
+#include "../include/10_BinaryTreePaths.h"
+
+
+void CreatBitTreeNode3(char str[][50], int return_count, TreeNode3* cur, int curIndex)
+{
+ if (str == NULL || return_count <= 0 || cur == NULL || curIndex >= return_count || curIndex < 0) {
+ return;
+ }
+ int last = return_count - 1;
+ if ((2 * curIndex + 1 <= last) && strcmp(str[2 * curIndex + 1], "NULL")) {
+ cur->left = (TreeNode3*)malloc(sizeof(TreeNode3));
+ if (NULL == cur->left) {
+ return;
+ }
+ cur->left->val = _ttoi(str[2 * curIndex + 1]);
+ }
+ else {
+ cur->left = NULL;
+ }
+ if ((2 * curIndex + 2 <= last) && strcmp(str[2 * curIndex + 2], "NULL")) {
+ cur->right = (TreeNode3*)malloc(sizeof(TreeNode3));
+ if (NULL == cur->right) {
+ return;
+ }
+ cur->right->val = _ttoi(str[2 * curIndex + 2]);
+ }
+ else {
+ cur->right = NULL;
+ }
+ CreatBitTreeNode3(str, return_count, cur->left, 2 * curIndex + 1);
+ CreatBitTreeNode3(str, return_count, cur->right, 2 * curIndex + 2);
+}
+TreeNode3* CreatBitTree3(char str[][50], int return_count)
+{
+ if (str == NULL || return_count <= 0) {
+ return NULL;
+ }
+ TreeNode3* head = (TreeNode3*)malloc(sizeof(TreeNode3));
+ if (NULL == head) {
+ return NULL;
+ }
+ head->val = _ttoi(str[0]);
+ CreatBitTreeNode3(str, return_count, head, 0);
+ return head;
+}
+void get_path(char** array, struct TreeNode3* root, int* returnSize, int* buf, int local)
+{
+ if (NULL == root) {
+ return;
+ }
+ if (!root->left && !root->right) {
+ char* str = (char*)malloc(1024);
+ int len = 0;
+ for (int i = 0; i < local; i++)
+ {
+ len += sprintf(str + len, "%d->", buf[i]);
+ }
+ sprintf(str + len, "%d", root->val);
+ array[(*returnSize)++] = str;
+ }
+ else {
+ buf[local++] = root->val;
+ get_path(array, root->left, returnSize, buf, local);
+ get_path(array, root->right, returnSize, buf, local);
+ }
+}
+char** binaryTreePaths(struct TreeNode3* root, int* returnSize) {
+ char** ret = (char**)malloc(sizeof(char*) * 1024);//һָ룬Ϊֵضάַ
+ *returnSize = 0;//άַԪظ
+ int buf[1024] = { 0 };//ջ
+ get_path(ret, root, returnSize, buf, 0);
+ return ret;
+}
+void free_tree3(TreeNode3* T)//ͷ
+{
+ if (!T) {
+ return;
+ }
+ if (T->left) {
+ free_tree3(T->left);
+ }
+ if (T->right) {
+ free_tree3(T->right);
+ }
+ if (T) {
+ free(T);
+ 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; //ַ
+}
\ No newline at end of file
diff --git a/Alogrithm/Alogrithm/src/main.cpp b/Alogrithm/Alogrithm/src/main.cpp
index 7490043..fec29a1 100644
--- a/Alogrithm/Alogrithm/src/main.cpp
+++ b/Alogrithm/Alogrithm/src/main.cpp
@@ -1,8 +1,33 @@
-#include "../include/2_ExcelSheetColumnTitle.h"
-#include "../include/3_bool IsUgly.h"
+#include "../include/10_BinaryTreePaths.h"
+
+
+
+
int main()
{
- //ExcelSheetColumnTitle(10);
- //printf("%d\n", IsUgly(6));
+
+ 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;
}