生活随笔
收集整理的這篇文章主要介紹了
数据结构源码笔记(C语言):基数排序
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
#include<stdio.h>
#include<malloc.h>
#include<string.h>#define MAXE 20
#define MAXR 10
#define MAXD 8 typedef struct node
{char data
[MAXD
];struct node
*next
;
}RecType
;void CreaLink(RecType
*&p
,char *a
[],int n
);void DispLink(RecType
*p
);void RadixSort(RecType
*&p
,int r
,int d
)
{RecType
*head
[MAXR
],*tail
[MAXR
],*t
;int i
,j
,k
;for(i
=d
-1;i
>=0;i
--){for(j
=0;j
<r
;j
++)head
[j
]=tail
[j
]=NULL;while(p
!=NULL){k
=p
->data
[i
]-'0';if(head
[k
]==NULL){head
[k
]=p
;tail
[k
]=p
;}else{tail
[k
]->next
=p
;tail
[k
]=p
;}p
=p
->next
;}p
=NULL;for(j
=0;j
<r
;j
++)if(head
[j
]!=NULL){if(p
==NULL){p
=head
[j
];t
=tail
[j
];}else {t
->next
=head
[j
];t
=tail
[j
];}}t
->next
=NULL;printf(" 按%d位排序:",d
-i
-1);DispLink(p
);}
}void CreaLink(RecType
*&p
,char *a
[],int n
)
{int i
;RecType
*s
,*t
;for(i
=0;i
<n
;i
++){s
=(RecType
*)malloc(sizeof(RecType
));strcpy(s
->data
,a
[i
]);if(i
==0){p
=s
;t
=s
;}else{t
->next
=s
;t
=s
;}}t
->next
=NULL;
}void DispLink(RecType
*p
)
{while(p
!=NULL){printf(" %s",p
->data
);p
=p
->next
;}printf("\n");
}int main()
{int n
=8;char * a
[]={"75","23","98","44","57","12","29","64","38","82"};RecType
*p
;CreaLink(p
,a
,n
);printf("\n");printf("初始化關鍵字:");DispLink(p
);RadixSort(p
,10,2);printf(" 最終結果:");DispLink(p
);printf("\n\n");return 0;
}
數據結構源碼筆記(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語言):二叉排序樹的基本操作算法
數據結構源碼筆記(C語言):B樹的相關運算算法
總結
以上是生活随笔為你收集整理的数据结构源码笔记(C语言):基数排序的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。