From 40d67765d033afb3ce7bac72f73de9ac08e1fd1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=82=96=E4=BC=8A=E4=B9=90?= <13452953+iyeji@user.noreply.gitee.com> Date: Fri, 8 Dec 2023 06:48:54 +0000 Subject: [PATCH] 2224020082 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 肖伊乐 <13452953+iyeji@user.noreply.gitee.com> --- 2224020082/exp7-1.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 2224020082/exp7-1.cpp diff --git a/2224020082/exp7-1.cpp b/2224020082/exp7-1.cpp new file mode 100644 index 00000000..08e6cdc6 --- /dev/null +++ b/2224020082/exp7-1.cpp @@ -0,0 +1,27 @@ +#include "btree.cpp" +int main() +{ BTNode *b,*p,*lp,*rp;; + printf("二叉树的基本运算如下:\n"); + printf(" (1)创建二叉树\n"); + CreateBTree(b,"A(B(D,E(H(J,K(L,M(,N))))),C(F,G(,I)))"); + printf(" (2)输出二叉树:");DispBTree(b);printf("\n"); + printf(" (3)H结点:"); + p=FindNode(b,'H'); + if (p!=NULL) + { lp=LchildNode(p); + if (lp!=NULL) + printf("左孩子为%c ",lp->data); + else + printf("无左孩子 "); + rp=RchildNode(p); + if (rp!=NULL) + printf("右孩子为%c",rp->data); + else + printf("无右孩子 "); + } + printf("\n"); + printf(" (4)二叉树b的高度:%d\n",BTHeight(b)); + printf(" (5)释放二叉树b\n"); + DestroyBTree(b); + return 1; +} \ No newline at end of file -- Gitee