摘要: usingSystem; namespaceShellSorter { publicclassShellSorter { publicvoidSort(int[]list) { intinc; for(inc=1;inc<=list.Length/9;inc=3*inc+1); for(;inc>0;inc/=3) { for(inti=inc+1;i<=list.Length;i+=inc) { intt=list[i-1]; intj=i; while((j>inc)&&(list[j-inc-1]>t)) { list[j-1]=list[j-inc-1]; j-=inc 阅读全文
posted @ 2007-06-25 13:35 似水流年-johnhuo 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 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[ 阅读全文
posted @ 2007-06-25 13:33 似水流年-johnhuo 阅读(122) 评论(0) 推荐(0) 编辑
摘要: usingSystem; namespaceBubbleSorter { publicclassBubbleSorter { publicvoidSort(int[]list) { inti,j,temp; booldone=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 @ 2007-06-25 13:32 似水流年-johnhuo 阅读(174) 评论(0) 推荐(0) 编辑
摘要: usingSystem; namespaceSelectionSorter { publicclassSelectionSorter { privateintmin; publicvoidSort(int[]list) { for(inti=0;i<list.Length-1;i++) { min=i; for(intj=i+1;j<list.Length;j++) { if(list[j]<list[min]) min=j; } intt=list[min]; list[min]=list[i]; list[i]=t; } } } publicclassMainClass { public. 阅读全文
posted @ 2007-06-25 13:30 似水流年-johnhuo 阅读(140) 评论(0) 推荐(0) 编辑