package com.myjavacode.sort;

public class TestSort1 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int arr[] = {99,94,95,93,92,91,90,89,97,88};
		System.out.println("----ǰ飺");
		TestSort1.printArr(arr);
		
		TestSort1.printArr(TestSort1.sort(arr));
		
		
		
	}
	
	public static void printArr(int[] arr) {
		for(int i=0; i<arr.length; i++) {
			System.out.print(arr[i]);
			if(i!=(arr.length-1))
				System.out.print(" ,");
			else
				System.out.println("");
		}
	}
	
	public static int[] sort(int[] arr) {
		for(int i=arr.length-1; i>0; i--) {
			for(int j=0; j<i; j++) {
				int tmp = 0;
				if(arr[j] > arr[j+1]) {
					tmp = arr[j+1];
					arr[j+1] = arr[j];
					arr[j] = tmp;
				}
			}
			System.out.print("--У "+i +" ");
			TestSort1.printArr(arr);
		}
		return arr;		
	}

}

@@ -25,16 +25,44 @@
 ort;%0D%0A%0D%0A
+import java.util.Random;%0D%0A%0D%0A
 public c
@@ -164,16 +164,18 @@
 stub%0D%0A%09%09
+//
 int arr%5B
@@ -212,16 +212,62 @@
 7,88%7D;%0D%0A
+%09%09int arr1%5B%5D = TestSort1.createArr(1000); //%0D%0A
 %09%09System
@@ -311,24 +311,25 @@
 printArr(arr
+1
 );%0D%0A%09%09%0D%0A%09%09Te
@@ -363,16 +363,17 @@
 sort(arr
+1
 ));%0D%0A%09%09%0D
@@ -929,14 +929,206 @@
 ;%09%09%0D%0A%09%7D%0D
+%0A%09%0D%0A%09public static int%5B%5D createArr(int i) %7B%0D%0A%09%09int%5B%5D arr = new int%5Bi%5D;%0D%0A%09%09Random ran = new Random();%0D%0A%09%09for(int j=0; j%3Ci; j++) %7B%0D%0A%09%09%09arr%5Bj%5D = ran.nextInt(1000000);%0D%0A%09%09%7D%0D%0A%09%09%0D%0A%09%09return arr;%0D%0A%09%7D%0D
 %0A%0D%0A%7D%0D%0A

Create Arrays randomly