⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 新建 文本文档.txt

📁 这是个数据结构的算法(二叉树的实现)
💻 TXT
字号:
#include"stdio.h"
#include"stddef.h"

typedef struct tree{
     char data;
     struct tree *rchild,lchild;
     }
 
stuct tree *createtree(struct tree *root,struct tree *r,char info)
 {
    if(!r)
      {
        r=(struct tree *)malloc(sizeof(struct tree));
        if(!r)
         { printf("mem over");
            exit(0);
         }
       r->rchild=NULL;
       r->lchild=NULL;
       r->data=info;
       if(!root)
          return r;
       if(info<root->data)
          return root->lchild=r;
        else
         retrun root->rchild=r;
          retrun r;
     }
   if (info<r->data)
     createtree(r,r->lchild,info);
   else
    createtree(r,r->rchild,info);
  retrun root;
}

void print_tree(struct tree *r)
{
  if(r)
   {
     printf("%c",r->data);
     print_tree(r->rchild);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -