資源簡介
10種排序算法代碼+綜合比較代碼(直接插入排序、希爾排序、冒泡排序、快速排序、簡單選擇排序、堆排序、歸并排序、基數排序、折半插入排序、2路插入排序),其中不僅有各種排序算法的代碼,還包含10種代碼在關鍵字比較次數、關鍵字移動次數以及實際排序時間的綜合比較代碼。
代碼片段和文件信息
#include
#include
#include
#define?N?100001
using?namespace?std;
long?long?sum[5][10][3];
int?randNum[N];
int?randNum1[N?-?1];
//顯示數組
void?show(int?randNum[N])?{
for?(int?i?=?1;?i? printf(“%6d“?randNum[i]);
cout?<}
//產生隨機數
void?proRandNum(int?*randNum)?{
randNum[0]?=?0;
srand((unsigned)clock());
for?(int?i?=?1;?i? randNum[i]?=?rand();
}
//產生正序
void?proPosiNum(int?*posiNum)?{
posiNum[0]?=?0;
for?(int?i?=?1;?i? posiNum[i]?=?i;
}
//產生逆序
void?proNegaNum(int?*negaNum)?{
negaNum[0]?=?0;
for?(int?i?=?1;?i? negaNum[i]?=?N-?i;
}
//前一半有序,后一半隨機
void?proPosiRandNum(int?*posiRand)?{
posiRand[0]?=?0;
for?(int?i?=?1;?i? posiRand[i]?=?i;
srand((un
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2019-05-30?14:51??Sort\
?????目錄???????????0??2019-05-30?14:51??Sort\bin\
?????目錄???????????0??2019-05-30?14:51??Sort\bin\Debug\
?????文件??????625584??2019-05-30?14:51??Sort\bin\Debug\Sort.exe
?????文件???????15543??2019-05-30?14:51??Sort\main.cpp
?????文件???????15384??2019-05-30?14:51??Sort\main.cpp.save
?????目錄???????????0??2019-05-30?14:51??Sort\obj\
?????目錄???????????0??2019-05-30?14:51??Sort\obj\Debug\
?????文件??????145053??2019-05-30?14:51??Sort\obj\Debug\main.o
?????文件????????1062??2019-05-30?14:51??Sort\Sort.cbp
?????文件?????????123??2019-05-30?14:51??Sort\Sort.depend
?????文件?????????244??2019-05-30?14:51??Sort\Sort.layout
?????文件?????????242??2019-05-30?14:51??Sort\Sort.layout.save
- 上一篇:STM32F4+MLX90614
- 下一篇:數據庫系統基礎教程英文版第三版答案
評論
共有 條評論