关于冒泡排序
public class BubbleSort {
/**
* @param args
*/
public static void main(String[] args) {
int x[]= {10,1,2,3,5,80};
new BubbleSort().bubbleSortOther(x);
for(int a:x){
System.out.println(a);
}
}
public void bubbleSort(int x[]){
int temp;
for(int i=0;i<x.length;i++){
for(int j=0;j<x.length-i-1;j++){
if(x[j]>x[j+1]){
temp = x[j];
x[j] = x[j+1];
x[j+1] = temp;
}
}
}
}
public void bubbleSortOther(int x[]){
int temp;
for(int i=0;i<x.length;i++){
for(int j=0;j<i;j++){
if(x[i]<x[j]){
temp = x[i];
x[i] = x[j];
x[j] = temp;
}
}
}
}
}