自己整理的排序算法之(1) 选择排序
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                自己整理的排序算法之(1) 选择排序
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.                        
                                
                            
                            
                             1 //選擇排序
 2 package sort;
 3 
 4 public class SelectionSort {
 5     public static void SelectionSort(double[] list){
 6         for(int i=0;i<list.length-1 ;i++){
 7             double currentMin = list[i];
 8             int currentMinIndex = i;
 9             
10             for(int k=i+1 ;k<list.length ; k++){
11                 if(currentMin>list[k]){
12                     currentMin = list[k];
13                     currentMinIndex = k;    
14                 }    
15             }
16             
17             if(currentMinIndex != i){
18                 
19                 list[currentMinIndex] = list[i];
20                 list[i] =currentMin; 
21             }
22         }
23     }
24     
25     public static void main(String[] args){
26         double[] list ={5.2 , 1.4 , 6.3,  2.3  ,4.6};
27         SelectionSort(list);
28         for(int i =0;i<list.length;i++){
29             System.out.print(list[i]+" ");
30         }
31     }
32 }  
                        
                        
                        ?
轉載于:https://www.cnblogs.com/kisty/p/5851230.html
總結
以上是生活随笔為你收集整理的自己整理的排序算法之(1) 选择排序的全部內容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: JavaScript对象的chapter
- 下一篇: Source insight 支持汇编
