运行结果正确
感觉堆还是比二叉搜索树容易实现
#include<stdio.h>
#include <stdlib.h>
#include <string.h>
#include<malloc.h>
//构造结构堆
typedef struct node *heap;
struct node {
//这是一个数组
int *base;
int max;
int size;
};
//遍历这个堆
void tra(heap h){
for(int i=1;i<=h->size;i++){
printf("%d ",h->base[i]);
}
printf("\n");
}
//初始化(第一个节点是守门员)
heap init