/**
* 实验题目:
* 实现学生信息的多关键字排序
* 实验目的:
* 掌握基数排序算法设计及其应用
* 实验内容:
* 假设有很多学生记录,每个学生记录包含姓名、性别和班号,
* 设计一个算法,按班号、性别有序输出,即先按班号输出,同一个
* 班的学生按性别输出。班号为1001~1030。编写程序,实现上述功能。
*/
#include <stdio.h>
#include <malloc.h>
#include <string.h>
#define MAXR 10
#define MAX_SIZE 10
typedef struct node
{
char xm[10]; // 姓名
char xb; // 性别 m:男 f:女
char bh[6]; // 班号
struct node *next; // 指向下一个结点的指针
}stud_node; // 学生单链表结点类型
typedef struct
{
char xm[10]; // 姓名
char xb; // 性别 m:男 f:女
char bh[6]; // 班号
}stud_type; // 学生记录类型
/**
* 功能:
* 由学生记录数组students创建单链表p
*
*/
static void create_link(stud_node *&p, stud_type students[], int n) // 指针的引用
{
int i;
stud_node *s, *t;
p = NULL;
for(i = 0; i < n; i++)
{
s = (stud_node *)malloc(sizeof(stud_node)); // 动态分配存储空间(新创建的结点)
strcpy(s->xm, students[i].xm);
s->xb = students[i].xb;
strcpy(s->bh, students[i].bh);
if(p == NULL)
{
p = s; // p