資源簡介
數據結構課程中的各種排序示例完整程序,用C語言實現 各種示例包括:希爾排序、選擇排序、插入排序、冒泡排序、快速排序等
代碼片段和文件信息
//折半插入排序的示例程序
#include
#define?MAXSIZE?20??//順序表的最大長度
typedef?int?KeyType;??//定義關鍵字類型為整數類型
typedef?char?InfoType;?//定義其它數據項
typedef?struct
{
KeyType?key;????????//關鍵字項
InfoType?otherinfo[20];?//其他數據項
}RedType;???????????????
typedef?struct
{
RedType?r[MAXSIZE+1];??//r[0]閑置或用作哨兵單元
int?length;????????????//順序表長度
}SqList;???????????????????//順序表類型
//void?InsertSort(SqList?&L);
void?BInsertSort(SqList?*L)
{//折半插入排序
int?i?j?low?high?m;
for(i=2;?ilength;?++i)
{
L->r[0]=L->r[i];?//將L[i]暫存到L[0]
low=1;
high=i-1;
while(low<=high)
{//在r[low...high]中折半查找有序插入的位置
m=(low+high)/2;???//折半
if(L->r[0].keyr[m].key)??
high=m-1;????//插入點在低半區
else
low=m+1;?????//插入點在高半區
}
for(j=i;?j>high+1;?--j)
L->r[j]=L->r[
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????1835??2012-06-27?16:30??Sort\BinaryInsertionSort\BinaryInsertionSort.c
?????文件???????4438??2012-06-27?17:30??Sort\BinaryInsertionSort\BinaryInsertionSort.dsp
?????文件????????961??2012-06-27?16:31??Sort\BinaryInsertionSort\BinaryInsertionSort.plg
?????文件?????168045??2012-06-27?16:31??Sort\BinaryInsertionSort\Debug\BinaryInsertionSort.exe
?????文件?????185180??2012-06-27?16:31??Sort\BinaryInsertionSort\Debug\BinaryInsertionSort.ilk
?????文件???????7412??2012-06-27?16:31??Sort\BinaryInsertionSort\Debug\BinaryInsertionSort.obj
?????文件?????175524??2012-06-27?15:41??Sort\BinaryInsertionSort\Debug\BinaryInsertionSort.pch
?????文件?????427008??2012-06-27?16:31??Sort\BinaryInsertionSort\Debug\BinaryInsertionSort.pdb
?????文件??????33792??2012-06-27?16:31??Sort\BinaryInsertionSort\Debug\vc60.idb
?????文件??????53248??2012-06-27?16:31??Sort\BinaryInsertionSort\Debug\vc60.pdb
?????文件???????1907??2012-06-28?14:48??Sort\BubbleSort\BubbleSort.c
?????文件???????4330??2012-06-28?14:49??Sort\BubbleSort\BubbleSort.dsp
?????文件????????916??2012-06-28?15:13??Sort\BubbleSort\BubbleSort.plg
?????文件?????168027??2012-06-28?15:13??Sort\BubbleSort\Debug\BubbleSort.exe
?????文件?????173952??2012-06-28?15:13??Sort\BubbleSort\Debug\BubbleSort.ilk
?????文件???????6773??2012-06-28?15:13??Sort\BubbleSort\Debug\BubbleSort.obj
?????文件?????175524??2012-06-28?14:48??Sort\BubbleSort\Debug\BubbleSort.pch
?????文件?????427008??2012-06-28?15:13??Sort\BubbleSort\Debug\BubbleSort.pdb
?????文件??????33792??2012-06-28?15:13??Sort\BubbleSort\Debug\vc60.idb
?????文件??????53248??2012-06-28?15:13??Sort\BubbleSort\Debug\vc60.pdb
?????文件?????168024??2012-06-29?15:21??Sort\QuickSort\Debug\QuickSort.exe
?????文件?????172784??2012-06-29?15:21??Sort\QuickSort\Debug\QuickSort.ilk
?????文件???????7980??2012-06-29?15:21??Sort\QuickSort\Debug\QuickSort.obj
?????文件?????175524??2012-06-29?15:20??Sort\QuickSort\Debug\QuickSort.pch
?????文件?????345088??2012-06-29?15:21??Sort\QuickSort\Debug\QuickSort.pdb
?????文件??????33792??2012-06-29?15:21??Sort\QuickSort\Debug\vc60.idb
?????文件??????53248??2012-06-29?15:21??Sort\QuickSort\Debug\vc60.pdb
?????文件???????2671??2012-06-29?15:21??Sort\QuickSort\QuickSort.c
?????文件???????4318??2012-06-28?22:25??Sort\QuickSort\QuickSort.dsp
?????文件????????910??2012-06-29?15:21??Sort\QuickSort\QuickSort.plg
............此處省略59個文件信息
- 上一篇:基于盲目搜索的寬度優先算法的八數碼的解決辦法
- 下一篇:C語言(C語言100題)
評論
共有 條評論