Selection Sort

2019-03-31  本文已影响0人  綿綿_
public class SelectionSort {
     static final int SIZE=10;
     public static void SelectSort(int[] a)
     {
         int temp, index;
         for (int i=0;i<a.length-1;i++)
         {
             index=i;
             for(int j=i+1;j<a.length;j++)
             {
                 if(a[j]>a[index])
                 {
                     index=j;
                 }
             }
             if(index!=i)
             {
                 temp=a[i];
                 a[i]=a[index];
                 a[index]=temp;
             }
             /*for(int h=0; h<a.length;h++)
             {
                 System.out.println(""+a[h]);
             }*/
         }
     }
}
上一篇 下一篇

猜你喜欢

热点阅读