91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

c語言實現的單鏈表和循環鏈表,沒有用到任何的庫,直接內存分配創建鏈表節點和刪除鏈表節點

資源截圖

代碼片段和文件信息

#include?
#include?
#include?
using?namespace?std;
#define?MAXSIZE?41
#define?OK?1
#define?ERROR?0
#define?TRUE?1
#define?FALSE?0
using?Statue?=?int;
using?ElemType?=?int;
using?pos?=?int;
struct?Node
{
????ElemType?data;
????Node?*next;
};
using?CircleLL?=?struct?Node*?;
//typedef?struct?Node?*CircleLL;
Statue?InitList(CircleLL?*L)
{
????*L?=?new?struct?Node;
????if(*L==nullptr)
????{
????????return?ERROR;
????}
????(*L)->next=*L;
????return?OK;
}
Statue?ListInsert(CircleLL?*Lpos?i??ElemType?e)
{
????CircleLL?p?q;
????int?j;
????p=*L;
????j=1;
????while(p->next!=*L?&&?j????{
p?=?p->next;
++j;
????}
if?(p->next==*L?||?j>i)
{
return?ERROR;
}
q?=?new?struct?Node;
q->data?=?e;
q->next?=?p->next;
?p->next?=?q;
?return?OK;
}
Statue?Listdelete(CircleLL?*Lpos?i?ElemType?*e)
{
CircleLL?p?q;
int?j;
p?=?*L;
j?=?1;
while?(p->next!=*L?&&?j {
p?=?p->next;
++j;
}
if?(p->next==*L?||?j>i)
{
return?ERROR;
}
q?=?p->next;
*e?=?q->data;
p->next?=?q->next;
delete?q;
return?OK;
}
Statue?searchList(CircleLL?*Lpos?&iElemType?e)
{
CircleLL?p=(*L)->next;
i=1;
while?(p->data?!=?e?&&?p?!=?*L)
{
p?=?p->next;
++i;
}
if?(p==*L)
{
i=-1;
return?ERROR;
}
else
{
return?OK;
}
}
void?creatListHead(CircleLL?*Lint?n=MAXSIZE)
{
CircleLL?p?;
int?i;
for?(i?=?0;?i? {
p?=?new?struct?Node;
p->data?=?i+1;
p->next?=?(*L)->next;
(*L)->next?=?p;
}
}
void?creatListTril(CircleLL?*Lint?n?=?MAXSIZE)
{
????CircleLL?pq;
????int?i?;
????q=*L;
????for(i=0;i????{
????????p=new?struct?Node;
????????p->data?=?i+1?;
????????q->next?=?p;
????????p->next?=?*L;
????????q=p;
????}
}
void?printL(CircleLL?*L)
{
CircleLL?p?=?(*L)->next;
while?(p!=*L)
{
cout?<data?< p=p->next;
}
cout?<}
int?main()
{
CircleLL?L;
InitList(&L);
creatListTril(&L);
// printL(&L);
//? ListInsert(&L10100);
//? printL(&L);
//? int?i;
//? Listdelete(&L10&i);
//? cout<<“刪除的元素是:“<//? printL(&L);
//? cout<<“請輸入要查找的元素:?“;
//? cin>>i;
//? pos?j;
//? searchList(&Lji);
//? cout<<“該元素所在位置是:?“< CircleLL?p?=?Lq;
pos?j;
while?(p)
{
p?=?p->next;
if?(p->next==L)
{
p->next?=?L->next;
break;
}
}
p?=?L->next;
while?(p->next!=p)
{
p?=?p->next;
q?=?p->next;
j?=?q->data;
p->next?=?q->next;
p?=?q->next;
cout?<“;
}
cout?<data< system(“pause“);
}

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????2609??2018-01-24?11:19??CirLL.cpp
?????文件?????????117??2017-12-25?02:36??main.cpp
?????文件????????2835??2018-01-23?16:59??linkList.cpp

評論

共有 條評論