-
大小: 1KB文件類型: .rar金幣: 2下載: 1 次發(fā)布日期: 2021-05-14
- 語言: 其他
- 標(biāo)簽:
資源簡介
課程設(shè)計的一部分代碼,希望能對大學(xué)生們做課設(shè)計有作用。

代碼片段和文件信息
/*【5.5】汽車牌照管理系統(tǒng)
[?問題描述?]?
?排序和查找是在數(shù)據(jù)處理中使用頻度極高的操作,為加快查找的速度需現(xiàn)對數(shù)據(jù)記錄按關(guān)鍵字?
排序。在汽車數(shù)據(jù)的信息模型中,汽車牌照是關(guān)鍵字,而且是具有結(jié)構(gòu)特點(diǎn)的一類關(guān)鍵字,因?
為汽車牌照號是數(shù)字和字母混編的,例如01B7328,這種記錄集合是一個適于利用多關(guān)鍵字進(jìn)行?
排序的典型例子。?
?[?基本要求?]?
?(1)首先利用鏈?zhǔn)交鶖?shù)排序方法實現(xiàn)排序,然后利用折半查找方法,實現(xiàn)對汽車記錄按關(guān)鍵字?
進(jìn)行查找。?
(2)汽車記錄集合可以人工錄入,也可以按自動方式隨機(jī)生成。?*/?
#include?
#define?RADIX?10
#define?DEY_SIZE?6
#define?LIST_SIZE?20
typedef?int?KeyType;
typedef?struct
{
KeyType?key[KEY_SIZE];
OtherType?other_data;
int?next;
}RecordTypel;
typedef?struct
{
RecordTypel?r[LIST_SIZE+1];
int?length;
int?keynum;
}SlinkList;
typedef?int?PVector[RADIX];
void?Distribute(?RecordTypel?r[]?int?i?PVector?head??PVector?tail)
{
for(?int?j=0;j<=RADIX-1;++j)
head[j]=0;
p=r[0].next;
while(p!=0)
{
j=Order();
if(head[j]==0)
head[j]=p;
else
r[tail[j]].next=p;
tail[j]=p;
p=r[p].next;
}
}
void?Collect?(?RecordTypel?r[]?int?i?PVector?head??PVector?tail)
{
j=0;
while(head[j]==0)
++j;
r[0].next=head[j];
t=tail[j];
while(j {
++j;
while(?(j ++j;
if(head[j]!=0)
{
r[t].next=head[j];
t=tail[j];
}
}
r[t].next=0;
}
void?RadixSort?(RecordType?r[]int?length)
{
n=length;
for(i=0;i<=n-1;++i)
r[i].next=i+1;
r[n].next=0;
d=keynum;
for(i=d-1;?i>=0;?--1)
{
Distribute(riheadtail);
Collect(rheadtail);
}
}
void?BinSrch(SpList?l KeyType?k)/*折半查找*/
{
low=1;high=;
while(low<=high)
{
mid=(low+high)/2;
if(k==l.r[mid].key)
return?mid;
else?if(k high=mid-1;
else
low=mid+1;
}
}
int?main()
{
RadixSort();
return?0;
}
/*?head=NULL;????鏈表的存儲方式???讀入方式可以采取頭插法建立鏈表的方法來對每個文件進(jìn)行讀取。多插法的具體操作
p=(Rnode*)malloc(sizeof(Rnode));
p->next=NULL;
while(?fscanf(f1“%s%s“p->keyp->name)!=EOF)
{
if(head==NULL)???l=head=p;
else
{
l->next=p;
l=p;
}
p=(Rnode*)malloc(sizeof(Rnode));
p->next=NULL;
}
*/
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????2250??2013-12-24?10:59??1.cpp
-----------?---------??----------?-----??----
?????????????????2250????????????????????1
評論
共有 條評論