#include
#include
using namespace std;
typedef struct Lnode{
int data;
struct Lnode*next;
}*LinkList;
void CreateHeadList(LinkList &L,int a[],int n){
LinkList s;
int i;
L=new Lnode;
L->next=NULL;
for(i=0;i
s=new Lnode;
s->data=a[i];
s->next=L->next;
L->next=s;
}
}
void DistroyList(LinkList &L){
LinkList pre=L,p=L->next;
while(p!=NULL){
delete(pre);
pre=p;
p=p->next;
}
int ListLenth(LinkList L){
int n=0;
LinkList p=L;
while(L!=NULL){
n++;
p=p->next;}
return(n);}
void Print(LinkList L)
{LinkList p=L->next;
while(p!=NULL){
cout<
p=p->next;
}cout< } bool GetElem(LinkList &L,int i,int &e){ LinkList p=L; for(int j=o;j p=p->next;} if(p==NULL) return false; else{ e=p->data; return true; } } int LocateEleme(LinkList &L,int e){ int i=1; LinkList p=L-next; while(p->data!=e&&p!=NULL){ i++; p=p->next; } if(p==NULL) return 0; else return i;} bool Listlnsert(LinkList &L,int i,int e){ LinkList p=L,s; int j=0; while(j j++; p=p->next;} if(p==NULL) return false; else { s=new Lnode; s->data=e; s->next=p->next; p->next=s; return true; } } int main(){ int a[]=12,52,64,3,31,58,49,65,61,67,2,8,9,7,6,2,4,64}; int n=18; LinkList L; cout<<"頭插法建立單鏈表"< CreateHeadList(L,a,n); cout<<"輸出結(jié)果為"< Print(L); cout<<"在第十個(gè)位置插入元素e"< int e=18; Listlnsert(L,10,e); cout<<"輸出結(jié)果為"< Print(L); cout<<"銷毀單鏈表"< DistroyList(L); } 你是否還在尋找穩(wěn)定的海外服務(wù)器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機(jī)房具備T級(jí)流量清洗系統(tǒng)配攻擊溯源,準(zhǔn)確流量調(diào)度確保服務(wù)器高可用性,企業(yè)級(jí)服務(wù)器適合批量采購(gòu),新人活動(dòng)首月15元起,快前往官網(wǎng)查看詳情吧
名稱欄目:實(shí)驗(yàn)算法描述-創(chuàng)新互聯(lián)
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計(jì)公司、網(wǎng)站策劃、軟件開(kāi)發(fā)、App開(kāi)發(fā)、虛擬主機(jī)、全網(wǎng)營(yíng)銷推廣
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源:
創(chuàng)新互聯(lián)
文章地址:http://vcdvsql.cn/article36/cccppg.html
猜你還喜歡下面的內(nèi)容