freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

數(shù)據(jù)結(jié)構(gòu)鄒永林版實(shí)驗(yàn)報(bào)告2-順序表與鏈表(已修改)

2025-07-07 07:23 本頁面
 

【正文】 實(shí)驗(yàn)二 順序表與鏈表【實(shí)驗(yàn)?zāi)康摹空莆站€性表中元素的前驅(qū)、后續(xù)的概念。掌握順序表與鏈表的建立、插入元素、刪除表中某元素的算法。對線性表相應(yīng)算法的時(shí)間復(fù)雜度進(jìn)行分析。理解順序表、鏈表數(shù)據(jù)結(jié)構(gòu)的特點(diǎn)(優(yōu)缺點(diǎn))?!緦?shí)驗(yàn)學(xué)時(shí)】2學(xué)時(shí)【實(shí)驗(yàn)預(yù)習(xí)】回答以下問題:順序表的存儲(chǔ)表示在順序表中,任一數(shù)據(jù)元素的存放位置是從起始位置開始、與該數(shù)據(jù)元素的位序成正比的對應(yīng)存儲(chǔ)位置,借助LOC(ai)=LOC(a1)+(i1)*1確定,則順序表是一種隨機(jī)存取的存儲(chǔ)結(jié)構(gòu)。單鏈表的存儲(chǔ)表示線性鏈表也稱單鏈表,在每一個(gè)結(jié)點(diǎn)中只包含一個(gè)指針,用于指示該結(jié)點(diǎn)的直接后繼結(jié)點(diǎn),整個(gè)鏈表通過指針相連,最后一個(gè)結(jié)點(diǎn)因?yàn)闆]有后繼結(jié)點(diǎn),其指針置為空(NULL)。這樣,鏈表中所有數(shù)據(jù)元素(結(jié)點(diǎn))構(gòu)成一對一的邏輯關(guān)系,實(shí)現(xiàn)線性表的鏈?zhǔn)酱鎯?chǔ)。【實(shí)驗(yàn)內(nèi)容和要求】實(shí)現(xiàn)順序表的相關(guān)操作。以下函數(shù)均具有返回值,若操作完成,返回OK,操作失敗返回ERROR。函數(shù)需返回的其他數(shù)據(jù),使用函數(shù)參數(shù)返回。:includeincludeincludedefine ERROR 0define MAXSIZE 100define OK 1typedef int ElemType。 /*定義表元素的類型*/typedef struct slist{ ElemType *list。 int listsize。 int length。}Sqlist。Sqlist *L。/*(1)補(bǔ)充順序表的存儲(chǔ)分配表示,采用定長和可變長度存儲(chǔ)均可*//*函數(shù)聲明*/int InitList_sq(Sqlist *L)。int CreateList_sq(Sqlist *L)。int ListInsert_sq(Sqlist *L,int i,ElemType e)。int PrintList_sq(Sqlist *L)。int ListDelete_sq(Sqlist *L,int i,ElemType *e)。int ListLocate(Sqlist *L,ElemType e,int *pos)。int menu_select()。/*(2)順序表的初始化*/int InitList_sq(Sqlist *L){ Llist=(ElemType *)malloc(MAXSIZE*sizeof(ElemType))。 if(Llist==NULL) return ERROR。 else { Llength=0。 Llistsize=MAXSIZE。 } return 0。}/*InitList*//*(3)創(chuàng)建具有n個(gè)元素的順序表*/int CreateList_sq(Sqlist *L){ int a,b,c。 printf(請輸入輸入數(shù)據(jù)的個(gè)數(shù)n:)。 scanf(%d,amp。a)。 printf(請輸入輸入的數(shù)據(jù):)。 for(b=0。ba。b++) { scanf(%d,amp。c)。 Llist[b]=c。 } Llength=Llength+a。 return 0。}/*CreateList*//*(4)輸出順序表中的元素*/int PrintList_sq(Sqlist *L){ int a。 printf(輸出數(shù)據(jù):)。 for(a=0。aLlength。a++) printf(%d ,Llist[a])。 return 0。}/*PrintList*//*(5)在順序表的第i個(gè)位置之前插入新元素e*/int ListInsert_sq(Sqlist *L,int i,ElemType e){ int a=Llength1。 for(。a=i1。a) Llist[a+1]=Llist[a]。 Llist[i1]=e。 Llength+=1。 return OK。}/*ListInsert*//*(6)在順序表中刪除第i個(gè)元素,e返回刪除的元素*/int ListDelete_sq(Sqlist *L,int i,ElemType *e){ int a=i1。 *e=Llist[i1]。 for(。aLlength。a++) Llist[a]=Llist[a+1]。 Llength=1。 return OK。}/* ListDelete_sq *//*(7)在順序表中查找指定值元素,pos為返回其位置序號*/int ListLocate(Sqlist *L,ElemType e,int *pos){ int a,b=0。 for(a=0。aLlength。a++) { if(e==Llist[a]) { b=0。 *pos=a+1。 break。 } else b=1。 } if(b==1) return 0。 else return OK。}/* ListLocate *//*定義菜單字符串?dāng)?shù)組*/int menu_select(){ char *menu[]={\n***************MENU******************\n, 1. Create List\n, /*創(chuàng)建順序表*/ 2. Get Element\n, /*查找順序表中的元素*/ 3. Insert data\n, /*插入數(shù)據(jù)*/ 4. Delete data\n, /*刪除數(shù)據(jù)*/ 0. Quit\n, /*退出*/ \n***************MENU******************\n }。 char s[3]。 /
點(diǎn)擊復(fù)制文檔內(nèi)容
畢業(yè)設(shè)計(jì)相關(guān)推薦
文庫吧 www.dybbs8.com
公安備案圖鄂ICP備17016276號-1