谁能帮我详细解释下这段程序 c++

来源:百度知道 编辑:UC知道 时间:2024/09/22 14:57:07
#include<stdio.h>
#include<stdlib.h>
#define D 2
#define R 10
#define N 11
typedef int KeyType;
typedef int DataType;
struct Node;
typedef struct Node radixNode;
struct Node
{
KeyType key[D];
/* DataType info; */
radixNode *next;
};
typedef radixNode * radixList;
typedef struct QueueNode
{
radixNode *f;
radixNode *e;
} Queue;
Queue queue[R];
void display(radixNode *plist)
{
int i;
radixNode *p;
p=plist->next;
while(p!=NULL)
{
printf("->");
for(i=0;i<D;i++)
printf("%1d",p->key[i]);
p=p->next;
}
printf("
");
}
void radixSort(radixNode *plist,int d,int r)
{
int i,j,k;
radixNode *p,*head;
head=plist->next;
for(j=d-1;j>=0;j--)
{
p=head;
for(i=0;i<r;i++)
{
queue[i].f=NULL;
queue[i].e=NULL;<

你哪里不懂,我给你解释哪里吧。

从头到尾的解释,有啥意思呢。如果是那样,说明你应该先好好的看看书去!

#include<stdio.h>
#include<stdlib.h>
#define D 2 //结点数据为二位数
#define R 10//十进制数
#define N 11//数组a[]总共有10个元素
typedef int KeyType;
typedef int DataType;
struct Node;
typedef struct Node radixNode;
struct Node
{
KeyType key[D];
/* DataType info; */
radixNode *next;
};
typedef radixNode * radixList;
typedef struct QueueNode
{
radixNode *f;
radixNode *e;
} Queue;
Queue queue[R];//队列数组,每个元素对应0-9的一个数字

void display(radixNode *plist)//输出链表,plist是链表的头结点
{
int i;
radixNode *p;
p=plist->next;
while(p!=NULL)
{
printf("->");
for(i=0;i<D;i++)//输出结点数据
printf("%1d",p->key[i]);
p=p->next;
}
printf("\n");
}
/*
本程序的精华:链式的基数排序
算法思想: 通过修改出队和人队函数使表示箱子的链队列无须分配结点空间,而使用原链表的结点空间。