欢迎指出代码不足
参考书本:严蔚敏《数据结构 .C语言版》
// RadixSort.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#define MAX_SIZE 1000//最大空间
#define RADIX 10//关键字基数
#define KEY_NUM 3//关键字个数
struct SLNode{//静态链表节点
int key;
int next;
};
struct SLList{//静态链表
SLNode base[MAX_SIZE];
int keyNum;//关键字数量
int len;
};
typedef int Arrtype [RADIX];//指针数组
void initList(SLList * list,int * array,int num){
for (int i = 0; i < num; i++){
list->base[i].next = i + 1;
list->base[i+1].key = array[i];
}
list->base[num].next = 0;
list->len = num;
list->keyNum = 3;
}
int ord(int key,int i){//获取地址 (0~9 )
if (i == 0){
return key % 10;
}
else if(i == 1){
return key % 100 / 10;
}
else{
return key / 100;
}
}
//分配函数
//i : 关键字 次数
//f: 队头指针数组
//e:队尾指针数组
void distribute(SLList * list,int i,Arrtype * f,Arrtype * e){
for (int j = 0; j < RADIX; j++) (*f