From 894e3d536b9925515d795f0a438400a2f4f6e4f5 Mon Sep 17 00:00:00 2001 From: sslmj2020 <57456161+sslmj2020@users.noreply.github.com> Date: Sun, 24 Nov 2024 00:39:33 +0800 Subject: [PATCH] Update array_binary_tree.cpp (#1568) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 打印的小错误 --- codes/cpp/chapter_tree/array_binary_tree.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/codes/cpp/chapter_tree/array_binary_tree.cpp b/codes/cpp/chapter_tree/array_binary_tree.cpp index 031c664c2..0b76df48a 100644 --- a/codes/cpp/chapter_tree/array_binary_tree.cpp +++ b/codes/cpp/chapter_tree/array_binary_tree.cpp @@ -115,9 +115,9 @@ int main() { int i = 1; int l = abt.left(i), r = abt.right(i), p = abt.parent(i); cout << "\n当前节点的索引为 " << i << ",值为 " << abt.val(i) << "\n"; - cout << "其左子节点的索引为 " << l << ",值为 " << (l != INT_MAX ? to_string(abt.val(l)) : "nullptr") << "\n"; - cout << "其右子节点的索引为 " << r << ",值为 " << (r != INT_MAX ? to_string(abt.val(r)) : "nullptr") << "\n"; - cout << "其父节点的索引为 " << p << ",值为 " << (p != INT_MAX ? to_string(abt.val(p)) : "nullptr") << "\n"; + cout << "其左子节点的索引为 " << l << ",值为 " << (abt.val(l) != INT_MAX ? to_string(abt.val(l)) : "nullptr") << "\n"; + cout << "其右子节点的索引为 " << r << ",值为 " << (abt.val(r) != INT_MAX ? to_string(abt.val(r)) : "nullptr") << "\n"; + cout << "其父节点的索引为 " << p << ",值为 " << (abt.val(p) != INT_MAX ? to_string(abt.val(p)) : "nullptr") << "\n"; // 遍历树 vector res = abt.levelOrder();