////冒泡排序
//using System;
//namespace BubbleSorter
//{
// public class BubbleSorter
// {
//  public void Sort(int[] list)
//  {
//   int i,j,temp;
//   bool done=false;
//   j = 1;
//   while((j<list.Length)&&(!done))
//   {
//    done=true;
//    for(i=0;i<list.Length-j;i++)
//    {
//     if(list[i] > list[i+1])
//     {
//      done=false;
//      temp=list[i];
//      list[i]=list[i+1];
//      list[i+1]=temp;
//     }
//    }
//    j++;
//   }
//
//  }
// }
// public class MainClass
// {
//  public static void Main()
//  {
//   int[] iArrary=new int[]{1,5,13,6,10,55,99,2,87,12,34,75,33,47};
//   BubbleSorter sh=new BubbleSorter();
//   sh.Sort(iArrary);
//   for(int m=0;m<iArrary.Length;m++)
//   Console.Write("{0} ",iArrary[m]);
//   Console.WriteLine();
//  }
// }
//}

////选择排序
//using System;
//
//namespace SelectionSorter{
// public class SelectionSorter{
//  private int min;
//  public void Sort(int[] sort){
//   for(int i = 0;i < sort.Length -1;i++){
//    min = i;
//    for(int j = i + 1;j < sort.Length;j++){
//     if(sort[j] < sort[min]){
//      min = j;
//     }
//     int t = sort[min];
//     sort[min] = sort[i];
//     sort[i] = t;
//    }
//   }
//  }
//  
// }
// public class MainClass{
//  public static void Main(){
//   int[] iArray = new int[]{1,5,3,6,10,55,9,2,87,12,34,75,33,47};
//   SelectionSorter ss = new SelectionSorter();
//   ss.Sort(iArray);
//   for(int m =0;m < iArray.Length;m++)
//    Console.Write(iArray[m] + " ");
//   Console.Read();
//    
//  }
// }
//}
//
////插入排序
//using System;
//namespace hc{
// public class InsertSort{
//  public void sort(int[] list){
//   for(int i = 1;i < list.Length;i++){
//    int t = list[i];
//    int j = i;
//    while((j > 0)&&(list[j-1] > t)){
//     list[j] = list[j-1];
//     --j;
//    }
//    list[j] = t;
//   }
//  }
// }
// public class MainClass{
//  public static void Main(){
//   int[] iArrary=new int[]{1,13,3,6,10,55,98,2,87,12,34,75,33,47};
//   InsertSort sort1 = new InsertSort();
//   sort1.sort(iArrary);
//   for(int m = 0;m < iArrary.Length;m++){
//    Console.WriteLine(iArrary[m]);
//   }
//  }
// }
//}

////希尔排序,希尔排序是将组分段,进行插入排序.
//using System;
//namespace hc{
// public class ShellSort{
//  public void Sort(int[] list){
//   int i;
//   for(i = 0; i <= list.Length/9;i=3*i+1);
//    for(;i > 0;i/=3)
//    {  for(int j = i + 1;j <= list.Length;j+=i){
//      int t = list[j-1];
//      int m = j;
//      while((m > i)&&(list[m-i-1] > t)){
//       list[m-1] = list[m-i-1];
//       m -=i;
//      }
//      list[m-1] = t;
//     }
//    }
//  }
//  
// }
// public class MainClass{
//  
//  public static void Main()
//  {
//   int[] iArrary=new int[]{1,13,3,6,10,55,98,2,87,12,34,75,33,47};
//   ShellSort sr = new ShellSort();
//   sr.Sort(iArrary);
//   for(int i =0;i < iArrary.Length;i++)
//    Console.WriteLine(iArrary[i]);
//   Console.Read();
//  }
// }
//}

////八皇后问题
//using System;
//namespace hc{
// class Queen
// {
//  const int SIZE = 8;//皇后数
//  public static void Main()
//  {
//   int[] Queen = new int [SIZE];//每行皇后的位置
//   int y,x,i,j,d,t=0;
//   y = 0;
//   Queen[0] = -1;
//   while( true )
//   {
//    for (x=Queen[y]+1; x<SIZE; x++)
//    {
//     for (i=0;i<y;i++)
//     {
//      j = Queen[i];
//      d = y-i;
//      //检查新皇后是否与以前的皇后能相互攻击
//      if ((j==x)||(j==x-d)||(j==x+d))
//       break;
//     }
//     if (i>=y)
//      break;//不攻击
//    }
//    if (x == SIZE) //没有合适的位置
//    {
//     if (0==y)
//     {
//      //回朔到了第一行
//      Console.WriteLine("Done");
//      break; //结束
//     }
//     //回朔
//     Queen[y]=-1;
//     y--;
//    }
//    else
//    {
//     Queen[y]=x;//确定皇后的位置
//     y++;//下一个皇后
//     if (y<SIZE)
//      Queen[y]=-1;
//     else
//     {
//      //所有的皇后都排完了,输出
//      Console.WriteLine("\n" + ++t +':');
//      for(i=0;i<SIZE;i++)
//      {
//       for (j=0;j<SIZE;j++)
//        if(Queen[i] == j)
//         Console.Write('Q');
//        else
//         Console.Write('.');
//       Console.WriteLine();
//      }
//      y = SIZE -1;//回朔
//     }
//    }
//   }
//   Console.Read();
//  }
// }
//
//}
//
////快速排序
//using System;  
//namespace QuickSorter
//{
// public class QuickSorter
// {
//  private void Swap(ref int l,ref int r)
//  {
//   int s;
//   s=l;
//   l=r;
//   r=s;
//  }
//  public void Sort(int [] list,int low,int high)
//  {
//   int pivot;
//   int l,r;
//   int mid;
//   if(high<=low)
//    return;
//   else if(high==low+1)
//   {
//    if(list[low]>list[high])
//     Swap(ref list[low],ref list[high]);
//    return;
//   }
//   mid=(low+high)>>1;
//   pivot=list[mid];
//   Swap(ref list[low],ref list[mid]);
//   l=low+1;
//   r=high;
//   do
//   {
//   while(l<=r&&list[l]<pivot)
//    l++;
//   while(list[r]>=pivot)
//    r--;
//    if(l<r)
//     Swap(ref list[l],ref list[r]);
//   }while(l<r);
//   list[low]=list[r];
//   list[r]=pivot;
//   if(low+1<r)
//    Sort(list,low,r-1);
//   if(r+1<high)
//    Sort(list,r+1,high);
//  }
// }
// public class MainClass
// {
//  public static void Main()
//  {
//   int[] iArrary=new int[]{1,5,3,6,10,55,9,2,87,12,34,75,33,47};
//   QuickSorter q=new QuickSorter();
//   q.Sort(iArrary,0,13);
//   for(int m=0;m<=13;m++)
//    Console.WriteLine("{0}",iArrary[m]);
//  }
// }
//  
//}