选择排序_排序算法_算法

选择排序:

  public static void Sort(int []array)
        {
            int temp = 0;
            int t = 0;
            for(int i=0;i<array.Length-1;i++)
            {
                temp = array[i];
                t = i;
                for (int j = i; j < array.Length;j++ )
                {
                    if (temp > array[j])
                    {
                        temp = array[j];
                        t = j;
                    }
                }
                if (t != i)
                {
                    array[t] = array[i];
                    array[i] = temp;
                }
            }
        }

 

posted on 2013-06-13 00:26  staben  阅读(121)  评论(0编辑  收藏  举报

导航