資源簡介
鏈表的歸并 數據結構 C語言實現

代碼片段和文件信息
//鏈表的歸并
#include
#include
struct?node?
{
???int?data;
???struct?node?*next;
};
//linklist?lalblc;
struct?node?*createlist(void);
struct?node?*margelist(struct?node?*lastruct?node?*lb);
void?putlist(struct?node?*head);
int?main(void)
{
??struct?node?*head*la*lb;
??la=createlist();
??lb=createlist();
??head=margelist(lalb);
??putlist(head);
??
??return?0;
}
struct?node?*createlist(void)
{
??????struct?node?*l*m*head;
??
??????l=m=(struct?node?*)malloc(sizeof(struct?node));
??????scanf(“%c“&l->data);
??head=NULL;
???while(l->data!=‘#‘)
???{
?????head=l;
?????m->next=l;
?m=l;
?l=(struct?node?*)malloc(sizeof(struct?node));
?????scanf(“%c“&l->data);
???}
???return?head;
}
struct?node?*mergelist(struct?node?*lastruct?node?*lb)
{
??struct?node?*pa*pb*pc*lc;
??pa=la->next;
??pb=lb->next;
??lc=pc=la;
??while(pa?&&?pb)
??{
????if(pa->next?<=?pb->next)
{
??pc->next?=?pa;
??pc?=pa;
??pa?=?pa->next;
}
else
{
?pc->next=pb;
?pc=pb;
?pb=pb->next;
}
??}
??pc->next?=?pa???pa?:?pb;
??free(lb);
??return?lc;
}
void?putlist(struct?node?*head)
{
??while(head?!=?NULL)
??{
????printf(“%d“head->data);
head=head->next;
??}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????4649??2011-09-26?11:46??鏈表的歸并\Debug\lianbiaogibing.obj
?????文件?????184772??2011-09-26?11:04??鏈表的歸并\Debug\lianbiaogibing.pch
?????文件??????25600??2011-09-26?11:47??鏈表的歸并\Debug\lianbiaogibing.pdb
?????文件??????33792??2011-09-26?11:47??鏈表的歸并\Debug\vc60.idb
?????文件??????53248??2011-09-26?11:46??鏈表的歸并\Debug\vc60.pdb
?????文件???????1265??2011-09-26?11:35??鏈表的歸并\lianbiaogibing.c
?????文件???????3495??2011-09-26?11:04??鏈表的歸并\lianbiaogibing.dsp
?????文件????????553??2011-09-26?11:53??鏈表的歸并\lianbiaogibing.dsw
?????文件??????33792??2011-09-26?11:53??鏈表的歸并\lianbiaogibing.ncb
?????文件??????48640??2011-09-26?11:53??鏈表的歸并\lianbiaogibing.opt
?????文件????????964??2011-09-26?11:47??鏈表的歸并\lianbiaogibing.plg
?????文件??????50176??2011-09-27?11:13??鏈表的歸并\鏈表歸并排序.doc
?????目錄??????????0??2012-03-03?13:17??鏈表的歸并\Debug
?????目錄??????????0??2012-03-03?13:17??鏈表的歸并
-----------?---------??----------?-----??----
???????????????440946????????????????????14
- 上一篇:MFC萬年歷制作
- 下一篇:模糊+PID C語言實現
評論
共有 條評論