bubblesort 冒泡排序 java

public class BubbleSort{
	public static void main(String args[]){
		int a []= {2,1,34,52,36,34,6,15,67,100,456};
		for(int i=0;i<a.length-1;i++){
			for(int j=0;j<a.length-1-i;j++){
				if(a[j]>a[j+1]){
					int temp = a[j];
					a[j]=a[j+1];
					a[j+1]=temp;
				}
			}
		}
        for(int z=0;z<a.length;z++){
        	System.out.print(a[z]+"/");
        }
	}
}
点赞