设为首页 加入收藏

TOP

数据结构实验叉树的建立(三)
2014-04-06 17:40:54 来源: 作者: 【 】 浏览:283
Tags:数据结构 实验 建立

 

  void zhong(bitree *p)

  {

  if(p)

  {

  zhong(p->left);

  printf("%c",p->data);

  zhong(p->right);

  }

  }

  void hou(bitree *p)

  {

  if (p)

  {

  hou(p->left);

  hou(p->right);

  printf("%c",p->data);

  if(p->left==NULL&&p->right==NULL)

  x++;

  }

  }

  int depth(bitree *p)

  {

  int ld, rd;

  if(p==NULL)

  return 0;

  ld=depth(p->left)+1;

  rd=depth(p->right)+1;

  return ld>rd ld:rd;

  }

  int main()

  {

  bitree *N;

  creatbitree(N);

  zhong(N);

  printf("\n");

  hou(N);

  printf("\n");

  printf("%d\n%d\n",x,depth(N));

  return 0;

  }

      

首页 上一页 1 2 3 下一页 尾页 3/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇C语言万年历代码 下一篇用C语言LZW编解码算法

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: