資料結構原始碼筆記(C語言) 直接選擇排序

2021-10-08 21:57:17 字數 2130 閱讀 8612

//實現直接選擇排序演算法

#include

#include

#define maxe 20

typedef

int keytype;

typedef

char infotype[10]

;typedef

struct

rectype;

void

selectsort

(rectype r,

int n)

// 直接選擇排序演算法

printf

(" i=%d "

,i);

//輸出每一趟的排序結果

for(l=

0;l)printf

("%4d"

,r[l]

.key)

;printf

("\n");

}}intmain()

; n=

sizeof

(a)/4;

rectype r[maxe]

;for

(i=0

;i) r[i]

.key=a[i]

;printf

("\n");

printf

("初始關鍵: ");

for(k=

0;k)printf

("%4d"

,r[k]

.key)

;printf

("\n");

selectsort

(r,n)

;printf

("最後結果: ");

for(k=

0;k)printf

("%4d"

,r[k]

.key)

;printf

("\n\n");

return0;

}

資料結構原始碼筆記(c語言描述)彙總:

資料結構原始碼筆記(c語言):英文單詞按字典序排序的基數排序

資料結構原始碼筆記(c語言):直接插入排序

資料結構原始碼筆記(c語言):直接選擇排序

資料結構原始碼筆記(c語言):置換-選擇演算法

資料結構原始碼筆記(c語言):huffman樹字元編碼

資料結構原始碼筆記(c語言):josephus問題之順序表

資料結構原始碼筆記(c語言):josephus問題之迴圈鏈結表

資料結構原始碼筆記(c語言):多項式合併

資料結構原始碼筆記(c語言):二叉樹之葉子結點旋轉銷毀

資料結構原始碼筆記(c語言):哈夫曼樹

資料結構原始碼筆記(c語言):集合的位向量表示

資料結構原始碼筆記(c語言):鏈結佇列

資料結構原始碼筆記(c語言):鏈結棧

資料結構原始碼筆記(c語言):線性表的單鏈表示

資料結構原始碼筆記(c語言):線性表的順序表示

資料結構原始碼筆記(c語言):棧的基本操作

資料結構原始碼筆記(c語言):中綴表示式

資料結構原始碼筆記(c語言):希爾插入排序

資料結構原始碼筆記(c語言):索引檔案建立和查詢

資料結構原始碼筆記(c語言):氣泡排序

資料結構原始碼筆記(c語言):快速排序

資料結構原始碼筆記(c語言):可變長度字串的快速排序

資料結構原始碼筆記(c語言):基數排序

資料結構原始碼筆記(c語言):二路歸併排序

資料結構原始碼筆記(c語言):堆排序

資料結構原始碼筆記(c語言):二叉樹搜尋樹kruskal

資料結構原始碼筆記(c語言):二叉搜尋樹prim

資料結構原始碼筆記(c語言):最短路徑弗洛伊德演算法

資料結構原始碼筆記(c語言):深度、廣度優先生成樹

資料結構原始碼筆記(c語言):鄰接矩陣轉化鄰接表

資料結構原始碼筆記(c語言):統計字串**現的字元及其次數

資料結構原始碼筆記(c語言):順序查詢

資料結構原始碼筆記(c語言):分塊法查詢

資料結構原始碼筆記(c語言):二分查詢

資料結構原始碼筆記(c語言):二叉樹遍歷

資料結構原始碼筆記(c語言):二叉平衡樹的相關操作演算法

資料結構原始碼筆記(c語言):二叉排序樹的基本操作演算法

資料結構原始碼筆記(C語言) 堆排序

實現堆排序演算法 include include define maxe 20 typedef int keytype typedef char infotype 10 typedef struct rectype void dispheap rectype r,int i,int n 按遞增有序進...

資料結構原始碼筆記(C語言) 鏈結棧

鏈結棧 型別和介面函式宣告 include include typedef int datatype struct node 單鏈表結點 typedef struct node pnode 指向結點的指標型別 struct node struct linkstack 鏈結棧型別定義 typedef ...

資料結構原始碼筆記(C語言) 置換 選擇演算法

實現置換 選擇演算法 include include include include define maxsize 20 typedef int infotype 定義其他資料項的型別 typedef int keytype 定義關鍵字型別為整型 struct redtype 記錄型別 define...