似水如衡

财上平如水 人中直似衡

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
 1 package com.learning.algorithm;
 2 
 3 public class SelectSort {
 4 
 5     public int[] selectSort(int[] arrValue){
 6         int temp = 0;
 7         int min;
 8         for(int i=0;i<arrValue.length-1;i++){
 9             min = i;
10             for(int j=i+1;j<arrValue.length;j++){
11                 if(arrValue[j]<arrValue[min]){
12                     min = j;
13                 }
14             }
15             temp = arrValue[i];
16             arrValue[i] = arrValue[min];
17             arrValue[min] = temp;
18         }
19         return arrValue;
20     }
21     
22     /**
23      * @param args
24      */
25     public static void main(String[] args) {
26         int[] arrValue = {89,39,56,93,2,58,43,51,33,67};
27         SelectSort ss = new SelectSort();
28         int[] arrResult = ss.selectSort(arrValue);
29         for(int value:arrResult){
30             System.out.print(value);
31             System.out.print(",");
32         }
33         
34 
35     }
36 
37 }

 

posted on 2014-08-23 17:32  似水如衡  阅读(140)  评论(0)    收藏  举报