- using System;
- namespace suanfa
- {
- /// <summary>
- /// SelectionSorter :选择排序算法。
- /// </summary>
- public class SelectionSorter
- {
- public SelectionSorter()
- {
- //
- // TODO: 在此处添加构造函数逻辑
- //
- }
- private int min;
- public void Sort(int [] list)
- {
- for(int i=0;i<list.Length-1;i++)
- {
- min=i;
- for(int j=i+1;j<list.Length;j++)
- {
- if(list[j]<list[min])
- min=j;
- }
- int t=list[min];
- list[min]=list[i];
- list[i]=t;
- }
- }
- }
- public class MainClassSelection
- {
- public static void MainSelection()
- {
- int[] iArrary=new int[]{1,5,13,6,10,55,99,2,87,12,34,75,33,47};
- SelectionSorter ss=new SelectionSorter();
- ss.Sort(iArrary);
- Console.WriteLine("选择算法排序:");
- for(int m=0;m<iArrary.Length;m++)
- Console.Write("{0} ",iArrary[m]);
- Console.WriteLine();
- Console.WriteLine();
- }
- }
- }