四種排序演算法:氣泡排序、選擇排序、插入排序和希爾排序
氣泡排序
using system;
namespace bubblesorter
} j++; }
} }
public class mainclass
; bubblesorter sh=new bubblesorter();
sh.sort(iarrary);
for(int m=0;m<iarrary.length;m++)
console.write(" ",iarrary[m]);
console.writeline();
} }
} 選擇排序
using system;
namespace selectionsorter
int t=list[min];
list[min]=list[i];
list[i]=t;
} }
} public class mainclass
; selectionsorter ss=new selectionsorter();
ss.sort(iarrary);
for(int m=0;m<iarrary.length;m++)
console.write(" ",iarrary[m]);
console.writeline();
} }
} 插入排序
using system;
namespace insertionsorter
list[j]=t; }
} }
public class mainclass
; insertionsorter ii=new insertionsorter();
ii.sort(iarrary);
for(int m=0;m<iarrary.length;m++)
console.write("",iarrary[m]);
console.writeline();
} }
} 希爾排序
希爾排序是將組分段,進行插入排序.
using system;
namespace shellsorter
list[j-1]=t;
} }
} }
public class mainclass
; shellsorter sh=new shellsorter();
sh.sort(iarrary);
for(int m=0;m<iarrary.length;m++)
console.write(" ",iarrary[m]);
console.writeline();
} }
}
C 四種排序演算法
c 四種排序演算法 sabine 本文介紹了c 的四種排序演算法 氣泡排序 選擇排序 插入排序 和希爾排序 氣泡排序 using system namespace bubblesorter public class mainclass bubblesorter sh new bubblesorter...
c 四種排序演算法!
1.氣泡排序 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 do...
C 四種排序演算法
的四種排序演算法 氣泡排序 選擇排序 插入排序和希爾排序 1 氣泡排序 using system namespace bubblesorter j public class mainclass bubblesorter sh new bubblesorter sh.sort iarrary for ...