java数据结构和算法------选择排序

 1 package iYou.neugle.sort;

 2 

 3 public class Select_sort {

 4     public static void SelectSort(double[] array) {

 5         for (int i = 0; i < array.length - 1; i++) {

 6             int tempIndex = i;

 7 

 8             for (int j = i + 1; j < array.length; j++) {

 9                 if (array[tempIndex] > array[j])

10                     tempIndex = j;

11             }

12 

13             double tempData = array[tempIndex];

14             array[tempIndex] = array[i];

15             array[i] = tempData;

16         }

17     }

18 }

 

你可能感兴趣的:(java)