欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

c語言函數(shù)單獨運行嗎 c語言函數(shù)單獨運行嗎

C語言實現(xiàn)數(shù)據(jù)結(jié)構(gòu)的線性鏈表,插入和刪除函數(shù)單獨運行的時候都正確,為什么先插入后刪除就運行不了?

//我只能說,代碼邏輯混亂,特橘棚別是索引,怎么是從1開始的,與一般邏輯不符(從0開始)

我們提供的服務(wù)有:成都網(wǎng)站建設(shè)、成都做網(wǎng)站、微信公眾號開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、鑲黃ssl等。為近1000家企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的鑲黃網(wǎng)站制作公司

//按照你的意圖修改如下,能正常運行了。

#includeiostream

#includestdlib.h

using namespace std;

#define null 0

typedef char ElemType;

typedef struct LNode

{

ElemType data;

struct LNode *next;

} LNode,*LinkList;

int ListLength(LinkList L) {

int n=0;

struct LNode*q=L;

if(L==NULL)

cout"鏈表為空"endl;

while(q!=NULL)

{

q=q-next;

n++;

}

return n;

}

ElemType GetElem(LinkList L,int i)

{

int j=1;

struct LNode*q=L;

while(jiq!=NULL)

{

q=q-next;

j++;

}

if(q!=NULL)

return (q-data);

else

cout"位置參數(shù)不正確"endl;

return 0;

}

void InsertList (LinkList L,ElemType x,int i)

{

int j=1;

struct LNode*q,*s;

s=new LNode;

s-data=x;

q=L;

if(i==1)

{

s-next=q;

L=s;

}

else

{

while(jiq-迅桐next!=NULL)

{

q=q-next;

j++;

}

if(j==i-1)

{

s-next=q-next;

q-next=s;

}

else

cout"位置參數(shù)不正確"endl;

}

}

int DeleteElem(LinkList L,int i)

{

int j=1;

struct LNode *q=L,*t;

if(i==1)

{

t=q;

L=q-next;

}

else

{

while(ji-1q-next!=NULL)

{

q=q-next;

j++;

}

if(q-next!=NULLj==i-1)

{

t-next=q-next;

q-next=t;

}

else

cout"位置參數(shù)不正圓昌則確"endl;

}

if(t)

delete t;

return 0;

}

void DisplayList(LinkList L)

{

struct LNode*q;

q=L;

cout"鏈表元素: ";

if(q==NULL)

cout"鏈表為空"endl;

else

{

while(q!=NULL)

{

coutq-data" ";

q=q-next;

}

}

coutendl;

}

void main()

{

LinkList LA = NULL;

ElemType cs;

int len=0;

InsertList(LA, 'a', 1);

InsertList(LA, 'B', 2);

InsertList(LA, 'C', 3);

cs=GetElem(LA, 3);

len=ListLength(LA);

DisplayList(LA);

}

當(dāng)前文章:c語言函數(shù)單獨運行嗎 c語言函數(shù)單獨運行嗎
文章來源:http://chinadenli.net/article27/dsphccj.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供做網(wǎng)站搜索引擎優(yōu)化虛擬主機網(wǎng)站策劃網(wǎng)站建設(shè)微信公眾號

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站制作