冒泡算法

public static void main(String[] args) {
int temp;
int[] aa = {22,23,55,78,223,8872,2,546,934,2,57};
for(int i = 0; i < aa.length; i++){
for(int j = 0; j < aa.length - i - 1; j++){
if(aa[j] > aa[j+1]){
temp = aa[j+1];
aa[j+1] = aa[j];
aa[j] = temp;
}
}
}
for(int i = 0; i < aa.length; ++i){
System.out.println("aa[" + i + "] is " + aa[i]);
}
}

你可能感兴趣的:(算法,String)