数据结构第六章一二次作业.docVIP

  • 4
  • 0
  • 约8.38千字
  • 约 13页
  • 2019-06-24 发布于浙江
  • 举报
上机题 (1)编写完整程序,用先序遍历法建立二叉树的二叉链 表存储结构。输出该二叉树的先、中、后序遍历结 点访问次序以及层次遍历结点访问次序。(建议结 点数据域类型为char) // erchashu.cpp : Defines the entry point for the console application. // #include stdafx.h #includestdio.h #includestdlib.h typedef struct node { char data; struct node *lchild, *rchild; }*BiT, BiTNode; BiT crtBT() { char ch; BiT bt; ch=getchar(); if(ch==#) return NULL; bt=new BiTNode(); bt-data=ch; bt-lchild=crtBT(); bt-rchild=crtBT(); return bt; } void preorder(BiT bt) { if(bt) { printf(%c,bt-data); preorder(bt-lchi

文档评论(0)

1亿VIP精品文档

相关文档