国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 金昌市| 怀安县| 韩城市| 东莞市| 乌拉特中旗| 蚌埠市| 菏泽市| 岳普湖县| 福建省| 抚顺县| 东源县| 高雄市| 泽州县| 峨眉山市| 成都市| 新泰市| 东平县| 湾仔区| 西丰县| 新竹县| 漳州市| 洪湖市| 锡林郭勒盟| 庆元县| 鹤峰县| 台东县| 综艺| 嘉峪关市| 伊春市| 江西省| 乡城县| 吴堡县| 稻城县| 逊克县| 长子县| 嘉禾县| 齐齐哈尔市| 北流市| 通榆县| 永春县| 靖安县|