package com.zzy.maopao;
public class paixun {
public static void main(String[] arge){
int[] array = {63,4,2,5,15,99,88,77,33};
paixun px = new paixun();
px.sort(array);
}
private void sort(int[] array) {
// TODO Auto-generated method stub
for(int i=1;i<array.length; i++){
for(int j=0; j<array.length-i;j++){
if(array[j]>array[j+1]){
int temp = array[j];
array[j] = array[j+1];
array[j+1] = temp;
}
}
}
showArray(array);
}
public void showArray(int[] array){
for(int i:array){
System.out.println(">"+i);
}
System.out.println();
}
}
后台粘贴出来结果:
>2 >4 >5 >15 >33 >63 >77 >88 >99
原文地址:http://12701034.blog.51cto.com/12691034/1929912