时间复杂度:$O(N^2)$
因为执行的次数为:$\frac{[1+(n-1)]*(n-1)}2\approx n^2$
1 for (int i=0;i<n-1;++i)
2 {
3 for (int j=0;j<n-1-i;++j)
4 {
5 if(array[j]>array[j+1]) // 按升序排列
6 {
7 int temp = array[j];
8 array[j] = array[j+1];
9 array[j+1] = temp;
10 }
11 }
12 }
原文:https://www.cnblogs.com/kachunyippp/p/10255261.html