您的位置:首页 > 其它

HeapSort自己yy-未完成

2016-12-08 22:37 211 查看
#include <iostream>
#include <cstdio>

using namespace std;

const int maxn=1e5+7;

int a[maxn];
int HeapSize;
int n;
//原子操作
//不要总想着搞一个大新闻,一次操作干太多操作
//只要不符合堆的性质我们就交换
void Heapify(){
int id=1;
while(id<=HeapSize){
int lson=2*id;
int rson=2*id+1;
int t;
if(lson>Heapsize&&rson>Heapsize){
break;
}
if(rson>HeapSize){
t=lson;
}
else if(a[lson]<a[rson]){
t=lson;
}
else{
t=rson;
}
if(a[t]<a[id]){
swap(a[t],a[id]);
}
id=t;
}
}
void MakeHeap(){

}
void HeapSort(){

}

int main(){
scanf("%d",&n);
HeapSize=n;
int i;
for(i=1;i<=n;++i){
scanf("%d",&a[i]);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: