usingSystem;namespaceInsertionSorter{publicclassInsertionSorter{publicvoidSort(int[]list){for(inti=1;i<list.Length;i++){intt=list[i];intj=i;while((j>0)&&(list[j-1]>t)){list[j]=list[j-1];--j;}list[j]=t;}}}publicclassMainClass{publicstaticvoidMain(){int[]iArrary=newint[]{1,13,3,6,10,55,98,2,87,12,34,75,33,47};InsertionSorterii=newInsertionSorter();ii.Sort(iArrary);for(intm=0;m<iArrary.Length;m++)Console.Write("{0}",iArrary[m]);Console.WriteLine();}}}

评论