#include<stdio.h>#include<stdlib.h>typedef struct node{ int data; struct node* left; struct node* right; }Node;typedef struct tree{ struct node* root;}Tree;char insert(Tree tree,char value){ if(value==NULL) return; else{ Node node=malloc(sizeof(node)); node->data=value; node->left=insert(node->left,value); node->right=insert(node->right,value);} return value;}int get_hight(Node *node){ int max; if(node==NULL) { return 0; } else { int left_h=get_hight(node->left); int right_h=get_hight(node->right); int max=left_h; if(right_h>left_h) { max=right_h; } } max=max+1; printf("%d",max); return max;}int count=0;int countleaf(Node *node,int count){ if(node==NULL) { return; } if(node!=NULL&&node->left==NULL&&node->right==NULL) { count++; } if(node!=NULL) { countleaf(node->left,count); countleaf(node->right,count); } return count;}int main(){ Node *node=NULL; Tree *tree=node; int i,j=0; char a[15]={'A','B','D',' ',' ',' ','C','E',' ','G',' ',' ','F',' ',' '}; for(i=0;i<15;i++) { insert(node,a[i]); printf("%c",a[i]); } countleaf(node,j); printf("%d",j); get_hight(node);} "#left")
2条回答 默认 最新
悬赏问题
- ¥20 求下下面这个数据结构代码
- ¥15 路由器考试怎么办,有懂行的吗 ,eNSP
- ¥20 前端 二进制文件流图片转化异常
- ¥15 github上的这个C语言项目如何跑起来
- ¥15 java 判断某个数 区间是否存在
- ¥15 appium控制多个雷电模拟器问题
- ¥15 C# iMobileDevice
- ¥15 谁会做这个啊#ensp#Boson NetSim
- ¥15 如何编写针对TPS6503320FRGE型号的电源管理芯片的编程代码?
- ¥15 设计简单目录管理系统,要满足以下内容