上一页 1 ··· 3 4 5 6 7 8 9 10 11 下一页

快速排序方法 by zhouwillpower

摘要: 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 return; else if(high==low+1) { if(list[low]list[high]) Swap(ref list[low],ref list[high]); 阅读全文
posted @ 2006-07-19 16:10 zhouwillpower 阅读(404) 评论(0) 推荐(0)

希尔排序方法 by zhouwillpower

摘要: using System; namespace ShellSorter { public class ShellSorter { public void Sort(int [] list) { int inc; for(inc=1;inc<=list.Length/9;inc=3*inc+1); for(;inc>0;inc/=3) { for(int i=inc+1;i<=list.Length;i+=inc) { int t=list[i-1]; int j=i; while((j>inc)&&(list[j-inc-1]>t)) { list[j-1]=list[j-inc-1]; j-=inc; } 阅读全文
posted @ 2006-07-19 15:58 zhouwillpower 阅读(229) 评论(0) 推荐(0)

插入排序方法 by zhouwillpower

摘要: 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, 阅读全文
posted @ 2006-07-19 15:57 zhouwillpower 阅读(419) 评论(0) 推荐(0)

选择排序方法 by zhouwillpower

摘要: using System; namespace SelectionSorter { public class SelectionSorter { 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 MainClass { p 阅读全文
posted @ 2006-07-19 15:56 zhouwillpower 阅读(187) 评论(0) 推荐(0)

冒泡排序方法 by zhouwillpower

摘要: 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++; } 阅读全文
posted @ 2006-07-19 15:55 zhouwillpower 阅读(205) 评论(0) 推荐(0)
上一页 1 ··· 3 4 5 6 7 8 9 10 11 下一页