三木社区

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 249|回复: 0
打印 上一主题 下一主题

C语言数据结构-main6-4.c

[复制链接]

1562

主题

1564

帖子

4904

积分

博士

Rank: 8Rank: 8

积分
4904
跳转到指定楼层
楼主
发表于 2017-9-1 09:17:49 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
  1. /* main6-4.c 检验bo6-4.c的主程序 */
  2. #include"c1.h"
  3. typedef char TElemType;
  4. TElemType Nil=' '; /* 以空格符为空 */
  5. #include"c6-4.h"
  6. #include"bo6-4.c"

  7. void vi(TElemType c)
  8. {
  9.    printf("%c ",c);
  10. }

  11. void main()
  12. {
  13.    int i;
  14.    PTree T,p;
  15.    TElemType e,e1;
  16.    InitTree(&T);
  17.    printf("构造空树后,树空否? %d(1:是 0:否) 树根为%c 树的深度为%d\n",TreeEmpty(T),Root(T),TreeDepth(T));
  18.    CreateTree(&T);
  19.    printf("构造树T后,树空否? %d(1:是 0:否) 树根为%c 树的深度为%d\n",TreeEmpty(T),Root(T),TreeDepth(T));
  20.    printf("层序遍历树T:\n");
  21.    TraverseTree(T,vi);
  22.    printf("请输入待修改的结点的值 新值: ");
  23.    scanf("%c%*c%c%*c",&e,&e1);
  24.    Assign(&T,e,e1);
  25.    printf("层序遍历修改后的树T:\n");
  26.    TraverseTree(T,vi);
  27.    printf("%c的双亲是%c,长子是%c,下一个兄弟是%c\n",e1,Parent(T,e1),LeftChild(T,e1),RightSibling(T,e1));
  28.    printf("建立树p:\n");
  29.    InitTree(&p);
  30.    CreateTree(&p);
  31.    printf("层序遍历树p:\n");
  32.    TraverseTree(p,vi);
  33.    printf("将树p插到树T中,请输入T中p的双亲结点 子树序号: ");
  34.    scanf("%c%d%*c",&e,&i);
  35.    InsertChild(&T,e,i,p);
  36.    Print(T);
  37.    printf("删除树T中结点e的第i棵子树,请输入e i: ");
  38.    scanf("%c%d",&e,&i);
  39.    DeleteChild(&T,e,i);
  40.    Print(T);
  41. }
复制代码


回复

使用道具 举报

Archiver|手机版|小黑屋|三木电子社区 ( 辽ICP备11000133号-4 )

辽公网安备 21021702000620号

GMT+8, 2024-4-21 00:16 , Processed in 0.046298 second(s), 22 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表