国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發(fā)設計 > 正文

排序二叉樹的形成

2019-11-08 02:40:12
字體:
來源:轉載
供稿:網友
#include<stdio.h>#include <malloc.h>#define Max 10typedef struct Tree{int data;struct Tree *lchild;struct Tree *rchild;}Tree;}*/void PRo(Tree **tree,int *a,int n);void pro(Tree **tree,int *a,int n){Tree *q=NULL;Tree *p=NULL;int k=0;if(n<Max){if(n==0){(*tree)=(Tree *)(malloc(sizeof(Tree)));(*tree)->lchild=NULL;(*tree)->rchild=NULL;(*tree)->data=a[n];pro(tree,a,n+1);}else{q=(Tree *)malloc(sizeof(Tree));q->lchild=NULL;q->rchild=NULL;q->data=a[n];p=(*tree);while(p->lchild&&p->data>q->data||p->rchild&&p->data<q->data){if(p->data>q->data){p=p->lchild;}else{p=p->rchild;}} if(p->data>q->data){p->lchild=q;}else{p->rchild=q;}pro(tree,a,n+1);}}}int main(){int a[Max]={5,6,45,0,47,7,9,1,65,9};Tree *tree=NULL;pro(&tree,a,0);printf("%d",tree->rchild->rchild->data);}
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 西华县| 宣威市| 板桥市| 甘南县| 江西省| 潞城市| 应用必备| 利津县| 天气| 枣庄市| 罗田县| 元阳县| 德庆县| 兴安县| 酒泉市| 礼泉县| 丰镇市| 肃宁县| 页游| 河池市| 宁强县| 临湘市| 正蓝旗| 孟津县| 广平县| 民县| 和硕县| 鱼台县| 淮滨县| 原阳县| 罗山县| 郸城县| 涟水县| 江阴市| 天门市| 雷波县| 秦皇岛市| 武鸣县| 临汾市| 新邵县| 汝阳县|