zoukankan      html  css  js  c++  java
  • 排序集合

    BubbleSort

    void BubbleSort(T V[],int n){
        for(int i;i<n;i++)
            for(int j=n-1;j>i;j--)
        if(V[j-1]>V[j]){
            T temp=V[j-1];
            V[j-1]=V[j];
            V[j]=temp;
        }
    }

    改进版BubbleSort

    void BubbleSort(T V[],int n)
    {
        bool exchange;
        for(int i; i<n; i++)
        {
            exchange=false;
            for(int j=n-1; j>i; j--)
                if(V[j-1]>V[j])
                {
                    T temp=V[j-1];
                    V[j-1]=V[j];
                    V[j]=temp;
                    exchange=true;
                }
            if(exchange==false)
                return ;
        }
    }
  • 相关阅读:
    p1297
    p2023
    p1612
    逆元总结
    p1652
    考试总结10-08
    p1459
    p1821
    p1863
    p1884
  • 原文地址:https://www.cnblogs.com/wangjianupc/p/10587203.html
Copyright © 2011-2022 走看看