冒泡排序

时间复杂度:$O(N^2)$

因为执行的次数为:$frac{[1+(n-1)]*(n-1)}2approx n^2$

 

for (int i=0;i<n-1;++i)
    {
        for (int j=0;j<n-1-i;++j) 
        { 
            if(array[j]>array[j+1])   // 按升序排列
            {
                int temp = array[j];
                array[j] = array[j+1];
                array[j+1] = temp;
            }
        }
    }
原文地址:https://www.cnblogs.com/kachunyippp/p/10255261.html