冒泡排序
package Hello;
import java.util.Arrays;
public class Hell0_four {
public static void main(String[] args) {
//冒泡排序
int[] a= {1,23,4,3,5,6,7,12};
int[] sort=sort(a);
System.out.println(Arrays.toString(sort));
}
public static int[] sort(int[] array) {
int x=0;//临时变量
for(int i = 0;i<array.length-1;i++) {
for(int j=0;j<array.length-1-i;j++) {
if(array[j+1]<array[j]) {
x=array[j];
array[j]=array[j+1];
array[j+1]=x;
}
}
}
return array;
}
}