标签:com test imageview oid href length gem pos block
重复比较相邻元素,择大者互换,从而完成排序
? @Test
public void Bubblesort() {
int[] data= {1, 4, 3, 2, 7, 6, 5, 8, 9, 0};
int position , scan,temp;
for (position=data.length-1; position >=0 ; position--) {
for (scan =0;scan<=position-1;scan++) {
if (data[scan]>(data[scan+1]))
{
temp=data[scan];
data[scan]=data[scan+1];
data[scan+1]=temp;
}
}
}
for (int a:data) System.out.println(a);
平均时间复杂度: O(n^2)
稳定的
优化方式参考:https://www.jianshu.com/p/f74fdcb2aa0c
标签:com test imageview oid href length gem pos block
原文地址:https://www.cnblogs.com/rainbowbridge/p/11410310.html