首页 - 图片 - 汽车 - 百科 - 旅游 - 美食 - 英语 - IT资讯 - 留学 - 移民 - 电影 - 下载 - 站点地图

您的位置: 易飞网 >> 资讯 >> 电脑网络 >> C#学习资料 >> 查看资讯

C#算法(二)插入排序

  朋友们,我最近加紧写C#的一些算法。选择排序已经推出的。现推出插入算法。
  对想提高C#语言编程能力的朋友,我们可以互相探讨一下。
  如:下面的程序,并没有实现多态,来,帮它实现一下。
  using System;
  public class InsertionSorter
  {
   public void Sort(int list)
   {
   for(int i=1;i<list.Length;++i)
   {
   int t=list;
   int j=i;
   while((j>0)&&(list>t))
   {
   list=list;
   --j;
   }
   list=t;
   }
  
   }
  }
  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};
   InsertionSorter ii=new InsertionSorter();
   ii.Sort(iArrary);
   for(int m=0;m<=13;m++)
   Console.WriteLine("{0}",iArrary);
   }
  }
  已经编译运行通过.这太简单了,我不做详细介绍了.