作者: 来自:网络

  插入排序算法。对想提高C#语言编程能力的朋友,我们可以互相探讨一下。如:下面的程序,并没有实现多态,来,帮它实现一下。
using System;


namespace InsertionSorter
{
 public class InsertionSorter
 {
  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};
   InsertionSorter ii=new InsertionSorter();
   ii.Sort(iArrary);
   for(int m=0;m<iArrary.Length;m++)
    Console.Write("{0}",iArrary[m]);
   Console.WriteLine();
  }
 }
}

相关文章:

  • 2022-12-23
  • 2022-03-10
  • 2022-12-23
  • 2021-06-17
  • 2021-08-25
  • 2021-07-01
  • 2021-05-02
猜你喜欢
  • 2021-09-11
  • 2022-12-23
  • 2021-07-02
  • 2021-10-05
  • 2021-12-04
相关资源
相似解决方案