From 08e49240541dbd3210197bfb67c98dca20a8a315 Mon Sep 17 00:00:00 2001 From: krahets Date: Fri, 4 Aug 2023 05:25:22 +0800 Subject: [PATCH] Finetune --- codes/c/chapter_tree/array_binary_tree.c | 2 ++ codes/javascript/chapter_divide_and_conquer/hanota.js | 4 ++-- codes/typescript/chapter_divide_and_conquer/hanota.ts | 4 ++-- docs/chapter_preface/index.md | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/codes/c/chapter_tree/array_binary_tree.c b/codes/c/chapter_tree/array_binary_tree.c index 7cbadbdaa..4f6b5c010 100644 --- a/codes/c/chapter_tree/array_binary_tree.c +++ b/codes/c/chapter_tree/array_binary_tree.c @@ -6,12 +6,14 @@ #include "../utils/common.h" +/* 数组表示下的二叉树类 */ struct arrayBinaryTree { vector *tree; }; typedef struct arrayBinaryTree arrayBinaryTree; +/* 构造函数 */ arrayBinaryTree *newArrayBinaryTree(vector *arr) { arrayBinaryTree *newABT = malloc(sizeof(arrayBinaryTree)); newABT->tree = arr; diff --git a/codes/javascript/chapter_divide_and_conquer/hanota.js b/codes/javascript/chapter_divide_and_conquer/hanota.js index 009d43253..92d3b6abf 100644 --- a/codes/javascript/chapter_divide_and_conquer/hanota.js +++ b/codes/javascript/chapter_divide_and_conquer/hanota.js @@ -28,7 +28,7 @@ function dfs(i, src, buf, tar) { } /* 求解汉诺塔 */ -function solveHanota(A, B, C) { +function hanota(A, B, C) { const n = A.length; // 将 A 顶部 n 个圆盘借助 B 移到 C dfs(n, A, B, C); @@ -44,7 +44,7 @@ console.log(`A = ${JSON.stringify(A)}`); console.log(`B = ${JSON.stringify(B)}`); console.log(`C = ${JSON.stringify(C)}`); -solveHanota(A, B, C); +hanota(A, B, C); console.log('圆盘移动完成后:'); console.log(`A = ${JSON.stringify(A)}`); diff --git a/codes/typescript/chapter_divide_and_conquer/hanota.ts b/codes/typescript/chapter_divide_and_conquer/hanota.ts index e5f0c55fe..8ee26b7d0 100644 --- a/codes/typescript/chapter_divide_and_conquer/hanota.ts +++ b/codes/typescript/chapter_divide_and_conquer/hanota.ts @@ -28,7 +28,7 @@ function dfs(i: number, src: number[], buf: number[], tar: number[]): void { } /* 求解汉诺塔 */ -function solveHanota(A: number[], B: number[], C: number[]): void { +function hanota(A: number[], B: number[], C: number[]): void { const n = A.length; // 将 A 顶部 n 个圆盘借助 B 移到 C dfs(n, A, B, C); @@ -44,7 +44,7 @@ console.log(`A = ${JSON.stringify(A)}`); console.log(`B = ${JSON.stringify(B)}`); console.log(`C = ${JSON.stringify(C)}`); -solveHanota(A, B, C); +hanota(A, B, C); console.log('圆盘移动完成后:'); console.log(`A = ${JSON.stringify(A)}`); diff --git a/docs/chapter_preface/index.md b/docs/chapter_preface/index.md index 39b1585a6..4307e17fd 100644 --- a/docs/chapter_preface/index.md +++ b/docs/chapter_preface/index.md @@ -9,5 +9,5 @@ !!! abstract 算法犹如美妙的交响乐,每一行代码都像韵律般流淌。 - + 愿这本书在你的脑海中轻轻响起,留下独特而深刻的旋律。