今天学习了冒泡排序,虽然C语言也学过,就当是复习了。

 1 public class TestBubbleSort {
 2         public static void main(String[] args) {
 3             
 4             int[] valuse = {33,55,66,32,78,45,39,98,76};
 5             int temp = 0;
 6             
 7             for(int j=0;j<valuse.length-1;j++){
 8                 for(int i=0;i<valuse.length-1-j;i++){
 9                     //比较大小
10                     if(valuse[i]>valuse[i+1]){
11                         temp = valuse[i];
12                         valuse[i] = valuse[i+1];
13                         valuse[i+1] = temp;                    
14                     }
15                     System.out.println(Arrays.toString(valuse));
16                 }
17                 System.out.println("##############"+j );
18                 System.out.println(Arrays.toString(valuse));
19             }
20      
21         }            
22 }