




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
實(shí)驗(yàn)二單向鏈表的基本操作實(shí)驗(yàn)?zāi)康恼莆站€性表鏈?zhǔn)酱鎯?chǔ)的方法及其基本操作掌握將算法在VC++語言環(huán)境下實(shí)現(xiàn)的過程實(shí)驗(yàn)準(zhǔn)備復(fù)習(xí)線性表的定義,掌握鏈?zhǔn)酱鎯?chǔ)的方法及操作復(fù)習(xí)C語言中指針及結(jié)構(gòu)體的概念。定義方式VC++的編程環(huán)境實(shí)驗(yàn)內(nèi)容28,20,12,9,7,5,4,3,1在你自己的文件下,建立一個(gè)C語言程序LL.C,完成下列要求:定義一個(gè)單鏈表LLIST,按數(shù)據(jù)1,3,4,5,7,9,12,20,28的次序建立各結(jié)點(diǎn),形成單鏈表LLIST,然后按鏈表順序輸出九個(gè)結(jié)點(diǎn)的存儲(chǔ)單元地址和相應(yīng)的數(shù)值;建立一個(gè)插入函數(shù),將數(shù)據(jù)15作為結(jié)點(diǎn)按照從小到大的次序自動(dòng)插入到鏈表的相應(yīng)位置上,完成插入結(jié)點(diǎn)的操作,形成新的鏈表LLIST,然后輸出鏈表結(jié)點(diǎn)的存儲(chǔ)單元地址和相應(yīng)的數(shù)值;建立一個(gè)刪除函數(shù),將鏈表中第七個(gè)結(jié)點(diǎn)刪除,形成新的鏈表LLIST,然后輸出鏈表結(jié)點(diǎn)的存儲(chǔ)單元地址和相應(yīng)的數(shù)值;程序清單如下:#include<stdio.h>#include<stdlib.h>#include<malloc.h>#defineNULL0typedefstructnode{intdata;sttuctnode*next;}llist;main(){llist*h,*crtll(),*insll(),*dltll();outll();h=NULL;h=crtll(h);outll(h);h=insll(h);outll(h);h=dltll(h);outll(h);}llist*crtll(llist*h){}voidoutll(llist*h){llist*y,*p;inti=1;y=h;while(y!=NULL){printf(“N=%dAD=%xDATA=%dAD->=%x\n”,i,y,y->data,y->next);y=y->next;i++;}}llist*insll(llist*h){}llist*dltll(llist*h){}#include"stdafx.h"#include<stdio.h>#include"stdlib.h"typedefstructLnode{ intdata; structLnode*next;}Lnode,*Link;voidcreate_list(Link&L){ Linkp,current;inta[]={28,20,12,9,7,5,4,3,1},j=8;L=(Link)malloc(sizeof(Lnode));L->next=NULL;current=L;while(j>=0){p=(Link)malloc(sizeof(Lnode));p->data=a[j];current->next=p;current=p;j--;}p->next=NULL;}voidprintf_list(Linkhead){Linkp;p=head->next;while(p!=NULL){ printf("%d=",p); printf("%d\n",p->data);p=p->next;}}voidinsert(Link&L){ inta=0; intn; Linkcurrent,p,q;q=(Link)malloc(sizeof(Lnode));printf("輸入一個(gè)插入的數(shù)\n");scanf("%d",&n);q->data=n; p=L; current=L->next;while((current!=NULL)&&a==0) { if(q->data<current->data)a=1; else { p=p->next; current=current->next; } } p->next=q; q->next=current;}voidDelete(Link&L){ intn;printf("輸入一個(gè)刪除的數(shù)\n");scanf("%d",&n);Linkcurrent,p; p=L; current=L->next; while(n!=current->data) { p=p->next; current=current->next; } p->next=current->next; free(current);}voidmain(){Linkhead;create_list(head);printf_list(head);insert(head);printf_list(head);Delete(head);printf_list(head);}#include"stdafx.h"#include<stdio.h>#include"stdlib.h"typedefstructLnode{ intdata; structLnode*next;}Lnode,*Link;voidcreate_list(Link&L){ Linkp,current;inta[]={28,20,12,9,7,5,4,3,1},j=8;L=(Link)malloc(sizeof(Lnode));L->next=NULL;current=L;while(j>=0){p=(Link)malloc(sizeof(Lnode));p->data=a[j];current->next=p;current=p;j--;}p->next=NULL;}voidprintf_list(Linkhead){Linkp;p=head->next;while(p!=NULL){ printf("%d=",p); printf("%d\n",p->data);p=p->next;}}voidinsert(Link&L){ inta=0; intn; Linkcurrent,p,q;q=(Link)malloc(sizeof(Lnode));printf("輸入一個(gè)插入的數(shù)\n");scanf("%d",&n);q->data=n; p=L; current=L->next;while((current!=NULL)&&a==0) { if(q->data<current->data)a=1; else { p=p->next; current=current->next; } } p->next=q; q->next=current;}voidDelete(Link&L){ intn;printf("輸入一個(gè)要?jiǎng)h除的數(shù)的位置\n");scanf("%d",&n);Linkcurrent,p; p=L; current=L->next;for(inti=1;i<n;i++){ p=p->next;current=current->next;}p->next=current->nex
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- GB/T 45231-2025智能床
- 全新合伙人合同:創(chuàng)始股東權(quán)利與義務(wù)
- 雙方戒煙合同責(zé)任書
- 船舶所有權(quán)變更合同
- 合同離婚改革:軍人家庭權(quán)益保障
- 5電磁鐵(教學(xué)設(shè)計(jì))-2024-2025學(xué)年六年級(jí)上冊科學(xué)教科版
- 項(xiàng)目融資及還款合同書范例
- 住宅租賃安全責(zé)任合同條款
- 知識(shí)產(chǎn)權(quán)保護(hù)及商業(yè)秘密合同范本
- 租賃合同模板范本:貨物運(yùn)輸設(shè)備
- 2024-2025年第二學(xué)期學(xué)校教導(dǎo)處工作計(jì)劃(二)
- 2025年蘇州衛(wèi)生職業(yè)技術(shù)學(xué)院高職單招職業(yè)技能測試近5年??及鎱⒖碱}庫含答案解析
- 二零二五年度博物館場地租賃與文物保護(hù)合作協(xié)議3篇
- 2025年春新人教版歷史七年級(jí)下冊全冊課件
- 2024年鐘山職業(yè)技術(shù)學(xué)院高職單招語文歷年參考題庫含答案解析
- 駱駝祥子-(一)-劇本
- 魏晉南北朝時(shí)期中外文化的交流
- 漁業(yè)行業(yè)智能化海洋牧場養(yǎng)殖方案
- 《工程勘察設(shè)計(jì)收費(fèi)標(biāo)準(zhǔn)》(2002年修訂本)
- 《債權(quán)法教學(xué)》課件
- 太傻天書(完整版)
評(píng)論
0/150
提交評(píng)論