你的分享就是我们的动力 ---﹥

洛谷P1177快速排序

时间:2017-01-19 20:43来源:www.chengxuyuans.com 点击:

#include<bits/stdc++.h>
using namespace std;
const int maxx = 100000 + 10;
int Heap[maxx];
int main() {
int n,num = 0,x;
scanf("%d",&n);
for(int i=1; i<=n; i++)
scanf("%d",&x),Heap[++num]=x,push_heap(Heap+1,Heap+num+1,greater<int>());
for(int i=1; i<=n; i++)
printf("%d ",Heap[1]),pop_heap(Heap+1,Heap+num+1,greater<int>()),num--;
return 0;
}

转载注明地址:http://www.chengxuyuans.com/code/C++/106620.html