zoukankan      html  css  js  c++  java
  • HeapSort自己yy-未完成

    #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;
    }
  • 相关阅读:
    邻接表(spfa模版)
    翻咸鱼(???)
    求逆序数
    Symmetry CSU
    Highways
    LightOJ
    G
    最长的斜坡。。。。
    快速幂取模
    二分
  • 原文地址:https://www.cnblogs.com/linkzijun/p/6147017.html
Copyright © 2011-2022 走看看