From 5392afd44b76a0c08c061ab5fb4b02d34d7704b0 Mon Sep 17 00:00:00 2001 From: krahets Date: Tue, 17 Oct 2023 23:45:31 +0800 Subject: [PATCH] fix several bugs --- codes/c/chapter_backtracking/preorder_traversal_i_compact.c | 2 +- codes/c/chapter_divide_and_conquer/CMakeLists.txt | 2 +- codes/c/chapter_hashing/hash_map_chaining.c | 2 +- codes/cpp/chapter_backtracking/permutations_i.cpp | 2 +- codes/csharp/chapter_backtracking/permutations_i.cs | 2 +- codes/dart/chapter_backtracking/permutations_i.dart | 2 +- codes/go/chapter_backtracking/permutations_i.go | 2 +- codes/java/chapter_backtracking/permutations_i.java | 2 +- codes/javascript/chapter_backtracking/permutations_i.js | 2 +- codes/rust/chapter_backtracking/permutations_i.rs | 2 +- codes/swift/chapter_backtracking/permutations_i.swift | 2 +- codes/typescript/chapter_backtracking/permutations_i.ts | 2 +- docs/chapter_array_and_linkedlist/list.md | 4 ++-- docs/chapter_hashing/hash_algorithm.md | 2 +- 14 files changed, 15 insertions(+), 15 deletions(-) diff --git a/codes/c/chapter_backtracking/preorder_traversal_i_compact.c b/codes/c/chapter_backtracking/preorder_traversal_i_compact.c index dec90b6c0..d9249b394 100644 --- a/codes/c/chapter_backtracking/preorder_traversal_i_compact.c +++ b/codes/c/chapter_backtracking/preorder_traversal_i_compact.c @@ -15,7 +15,7 @@ void printFunc(vector *v, void *p) { } /* 前序遍历:例题一 */ -static void preOrder(TreeNode *root) { +void preOrder(TreeNode *root) { if (root == NULL) { return; } diff --git a/codes/c/chapter_divide_and_conquer/CMakeLists.txt b/codes/c/chapter_divide_and_conquer/CMakeLists.txt index 2f313319d..e03b1c588 100644 --- a/codes/c/chapter_divide_and_conquer/CMakeLists.txt +++ b/codes/c/chapter_divide_and_conquer/CMakeLists.txt @@ -1,3 +1,3 @@ add_executable(binary_search_recur binary_search_recur.c) -add_executable(hanota hanota.c) add_executable(build_tree build_tree.c) +add_executable(hanota hanota.c) diff --git a/codes/c/chapter_hashing/hash_map_chaining.c b/codes/c/chapter_hashing/hash_map_chaining.c index e4e9d25a3..790f5404c 100644 --- a/codes/c/chapter_hashing/hash_map_chaining.c +++ b/codes/c/chapter_hashing/hash_map_chaining.c @@ -19,7 +19,7 @@ typedef struct pair Pair; /* 链表节点 */ struct node { Pair *pair; - struct Node *next; + struct node *next; }; typedef struct node Node; diff --git a/codes/cpp/chapter_backtracking/permutations_i.cpp b/codes/cpp/chapter_backtracking/permutations_i.cpp index c49867e20..86eb1df18 100644 --- a/codes/cpp/chapter_backtracking/permutations_i.cpp +++ b/codes/cpp/chapter_backtracking/permutations_i.cpp @@ -16,7 +16,7 @@ void backtrack(vector &state, const vector &choices, vector &sel // 遍历所有选择 for (int i = 0; i < choices.size(); i++) { int choice = choices[i]; - // 剪枝:不允许重复选择元素 且 不允许重复选择相等元素 + // 剪枝:不允许重复选择元素 if (!selected[i]) { // 尝试:做出选择,更新状态 selected[i] = true; diff --git a/codes/csharp/chapter_backtracking/permutations_i.cs b/codes/csharp/chapter_backtracking/permutations_i.cs index 7c3fba4a5..40ffdc3f8 100644 --- a/codes/csharp/chapter_backtracking/permutations_i.cs +++ b/codes/csharp/chapter_backtracking/permutations_i.cs @@ -17,7 +17,7 @@ public class permutations_i { // 遍历所有选择 for (int i = 0; i < choices.Length; i++) { int choice = choices[i]; - // 剪枝:不允许重复选择元素 且 不允许重复选择相等元素 + // 剪枝:不允许重复选择元素 if (!selected[i]) { // 尝试:做出选择,更新状态 selected[i] = true; diff --git a/codes/dart/chapter_backtracking/permutations_i.dart b/codes/dart/chapter_backtracking/permutations_i.dart index 29988721b..2987f32cb 100644 --- a/codes/dart/chapter_backtracking/permutations_i.dart +++ b/codes/dart/chapter_backtracking/permutations_i.dart @@ -19,7 +19,7 @@ void backtrack( // 遍历所有选择 for (int i = 0; i < choices.length; i++) { int choice = choices[i]; - // 剪枝:不允许重复选择元素 且 不允许重复选择相等元素 + // 剪枝:不允许重复选择元素 if (!selected[i]) { // 尝试:做出选择,更新状态 selected[i] = true; diff --git a/codes/go/chapter_backtracking/permutations_i.go b/codes/go/chapter_backtracking/permutations_i.go index ceebbf4ea..ed50ece9c 100644 --- a/codes/go/chapter_backtracking/permutations_i.go +++ b/codes/go/chapter_backtracking/permutations_i.go @@ -14,7 +14,7 @@ func backtrackI(state *[]int, choices *[]int, selected *[]bool, res *[][]int) { // 遍历所有选择 for i := 0; i < len(*choices); i++ { choice := (*choices)[i] - // 剪枝:不允许重复选择元素 且 不允许重复选择相等元素 + // 剪枝:不允许重复选择元素 if !(*selected)[i] { // 尝试:做出选择,更新状态 (*selected)[i] = true diff --git a/codes/java/chapter_backtracking/permutations_i.java b/codes/java/chapter_backtracking/permutations_i.java index b4d104e06..b6029644f 100644 --- a/codes/java/chapter_backtracking/permutations_i.java +++ b/codes/java/chapter_backtracking/permutations_i.java @@ -19,7 +19,7 @@ public class permutations_i { // 遍历所有选择 for (int i = 0; i < choices.length; i++) { int choice = choices[i]; - // 剪枝:不允许重复选择元素 且 不允许重复选择相等元素 + // 剪枝:不允许重复选择元素 if (!selected[i]) { // 尝试:做出选择,更新状态 selected[i] = true; diff --git a/codes/javascript/chapter_backtracking/permutations_i.js b/codes/javascript/chapter_backtracking/permutations_i.js index c0533eda3..8981fc4b4 100644 --- a/codes/javascript/chapter_backtracking/permutations_i.js +++ b/codes/javascript/chapter_backtracking/permutations_i.js @@ -13,7 +13,7 @@ function backtrack(state, choices, selected, res) { } // 遍历所有选择 choices.forEach((choice, i) => { - // 剪枝:不允许重复选择元素 且 不允许重复选择相等元素 + // 剪枝:不允许重复选择元素 if (!selected[i]) { // 尝试:做出选择,更新状态 selected[i] = true; diff --git a/codes/rust/chapter_backtracking/permutations_i.rs b/codes/rust/chapter_backtracking/permutations_i.rs index 3c41a458c..96364783d 100644 --- a/codes/rust/chapter_backtracking/permutations_i.rs +++ b/codes/rust/chapter_backtracking/permutations_i.rs @@ -14,7 +14,7 @@ fn backtrack(mut state: Vec, choices: &[i32], selected: &mut [bool], res: & // 遍历所有选择 for i in 0..choices.len() { let choice = choices[i]; - // 剪枝:不允许重复选择元素 且 不允许重复选择相等元素 + // 剪枝:不允许重复选择元素 if !selected[i] { // 尝试:做出选择,更新状态 selected[i] = true; diff --git a/codes/swift/chapter_backtracking/permutations_i.swift b/codes/swift/chapter_backtracking/permutations_i.swift index 51ab05b16..defe7511e 100644 --- a/codes/swift/chapter_backtracking/permutations_i.swift +++ b/codes/swift/chapter_backtracking/permutations_i.swift @@ -13,7 +13,7 @@ func backtrack(state: inout [Int], choices: [Int], selected: inout [Bool], res: } // 遍历所有选择 for (i, choice) in choices.enumerated() { - // 剪枝:不允许重复选择元素 且 不允许重复选择相等元素 + // 剪枝:不允许重复选择元素 if !selected[i] { // 尝试:做出选择,更新状态 selected[i] = true diff --git a/codes/typescript/chapter_backtracking/permutations_i.ts b/codes/typescript/chapter_backtracking/permutations_i.ts index 17513a5a6..33900dd5e 100644 --- a/codes/typescript/chapter_backtracking/permutations_i.ts +++ b/codes/typescript/chapter_backtracking/permutations_i.ts @@ -18,7 +18,7 @@ function backtrack( } // 遍历所有选择 choices.forEach((choice, i) => { - // 剪枝:不允许重复选择元素 且 不允许重复选择相等元素 + // 剪枝:不允许重复选择元素 if (!selected[i]) { // 尝试:做出选择,更新状态 selected[i] = true; diff --git a/docs/chapter_array_and_linkedlist/list.md b/docs/chapter_array_and_linkedlist/list.md index 36b7eb6b2..a43cfe913 100755 --- a/docs/chapter_array_and_linkedlist/list.md +++ b/docs/chapter_array_and_linkedlist/list.md @@ -233,9 +233,9 @@ ```rust title="list.rs" /* 访问元素 */ - let num: i32 = nums[1]; // 访问索引 1 处的元素 + let num: i32 = nums[1]; // 访问索引 1 处的元素 /* 更新元素 */ - nums[1] = 0; // 将索引 1 处的元素更新为 0 + nums[1] = 0; // 将索引 1 处的元素更新为 0 ``` === "C" diff --git a/docs/chapter_hashing/hash_algorithm.md b/docs/chapter_hashing/hash_algorithm.md index 4c1365e6b..14099c64d 100644 --- a/docs/chapter_hashing/hash_algorithm.md +++ b/docs/chapter_hashing/hash_algorithm.md @@ -223,7 +223,7 @@ $$ === "Go" ```go title="built_in_hash.go" - + // Go 未提供内置 hash code 函数 ``` === "Swift"