void heapup(){
int i=a[0];
while(i>1&&a[i]<a[i/2]){
swap(a[i],a[i/2]);
i/=2;
}
}
void heapdown(){
int i=1,j;
while(i*2<=a[0]){
if(i*2==a[0]||a[i*2]<a[i*2+1]){
j=i*2;
}else{
j=i*2+1;
}
if(a[i]>a[j]){
swap(a[i],a[j]);
i=j;
}else{
break;
}
}
}
void setheap(int c){
a[++a[0]]=c;
heapup();
}
void del(){
a[1]=a[a[0]--];
heapdown();
}
标签:int,void,else,heapdown,手写,heapup
From: https://www.cnblogs.com/As-Snow/p/16889948.html