


下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、課程名稱:數(shù)據(jù)結(jié)構(gòu)與算法成績評定:實(shí)驗(yàn)項(xiàng)目名稱:單鏈表的基本操作指導(dǎo)教師:學(xué)生姓名:沈麗桃學(xué)號(hào): 10403080118 專業(yè)班級(jí): 10 教育技術(shù)實(shí)驗(yàn)項(xiàng)目類型:驗(yàn)證實(shí)驗(yàn)地點(diǎn):科 b305 實(shí)驗(yàn)時(shí)間: 2011 年 10 月 20 日一、實(shí)驗(yàn)?zāi)康呐c要求:實(shí)驗(yàn)?zāi)康模?實(shí)現(xiàn)線性鏈表的創(chuàng)建、查找、插入、刪除與輸出?;驹恚?單鏈表的基本操作二、實(shí)驗(yàn)環(huán)境:(硬件環(huán)境、軟件環(huán)境)1.硬件環(huán)境:奔pc。2.軟件環(huán)境: windows xp 操作系統(tǒng), tc2.0 或 vc。三、實(shí)驗(yàn)內(nèi)容:(原理、操作步驟、程序代碼等)#include #include #include struct celltype i
2、nt element; struct celltype*next; ; typedef int position; void main() struct celltype*head,*p; int x,choice; void insert(int x,struct celltype*p); void locate(int x,struct celltype*p); void delete(int x,struct celltype*p); p=(struct celltype*)malloc(sizeof(struct celltype); head=p; p-element=0; p-ne
3、xt=null; printf(“please option:1:insert 2:locate 3:deleten”); printf(“please choose:”); scanf(“%d ”,&choice); switch(choice) case 1: printf(“please input a node:”); scanf(“%d ”,&x); 湖南第一師范學(xué)院信息科學(xué)與工程系實(shí)驗(yàn)報(bào)告 p=head; insert(x,p); for(p=head;p!=null;p=p-next) printf(“ %d ”,p-element); printf(“n ”);
4、 break; case 2: printf(“please input the data you want to locate:”); scanf(“%d ”,&x); p=head; locate(x,p); break; case 3: printf(“please input the data you want to delete:”); scanf(“%d ”,&x); delete(x,p); for(p=head;p!=null;p=p-next) printf(“%d ”,p-next); printf(“n ”); break; void insert(int
5、 x,struct celltype*p) struct celltype*t,*q; q=(struct celltype*)malloc(sizeof(struct celltype); q-next=x; while(xp-element)&(p!=null) t=p; p=p-next; if(xp-element)&(p-next!=null) p-next=q; q-next=null; else q-next=p; t-next=q; void locate(int x,struct celltype*p) while(p-next!=null) if(p-nex
6、t-element=x) printf(“the number %d is in %dn”,x,p); else printf(“the number not exist!n” ); void delete(int x,struct celltype*p) while(p-element!=x)&(p-next!=null) t=p; p=p-next; if(p-element=x) t-next=p-next error c2018:unknown character oxalerror c2065:please :undeclared identifier error c4024
7、:printf:different types for formal and actual parameter 1 error c4047: function: const*differs in levers of indirection from int error c2146:syntaxerror:missing) before identifieroption error c2017:illegal escape sequence error c2059:syntax error:) error c2143:syntax error:missing) before % 出現(xiàn)了很多錯(cuò)誤,
8、主要是因?yàn)閜rintf里的一對雙引號(hào)不是英文狀態(tài)下的。將雙引號(hào)改好后,錯(cuò)誤消失,輸入時(shí)應(yīng)注意細(xì)節(jié),最好直接在編譯環(huán)境下輸程序error c2043:illegal break error c2043:illegal case error c2198:scanf :too few actual parameters 這里是由于每一個(gè)case 間應(yīng)有縮進(jìn),或者用大括號(hào)括起來。error c2065: t:undeclared identifier warning c4047:=: struct celltype*differs in levers of indirection 這個(gè)錯(cuò)誤是p-next=x,應(yīng)改為 p-element=x error c2223:left of-next must point to struct/union 這里是由于t 沒有定義,還有最后一個(gè)語句后沒有分號(hào)。四、實(shí)驗(yàn)體會(huì)注意細(xì)節(jié),像拼寫錯(cuò)誤就該避免,要注意所有符號(hào)必須是英文狀態(tài)下的。所有變量必須定義清楚,在用 switch 語句時(shí),注意每個(gè)cas
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(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ǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 英語主題閱讀-五年級(jí)英語
- 海外務(wù)工人員權(quán)益保護(hù)擔(dān)保合同模板
- 車間安全生產(chǎn)事故調(diào)查與處理合同
- 野餐食物承包方案
- 應(yīng)急廣播拆除方案
- 特殊機(jī)構(gòu)規(guī)劃方案模板
- 成都市長租公寓租賃合同書含租客入住前檢查
- 業(yè)務(wù)合作方案書
- 施工企業(yè)信貸支持方案
- 吳中數(shù)學(xué)面試題及答案
- 2024中儲(chǔ)糧集團(tuán)財(cái)務(wù)限公司人員招聘公開招聘歷年考點(diǎn)共500題附帶答案
- 村務(wù)監(jiān)督主任培訓(xùn)會(huì)-深化整治群眾身邊不正之風(fēng) 筑牢基層監(jiān)督防線
- 藥品追溯管理制度培訓(xùn)
- 2024年安徽省合肥市北城片區(qū)七年級(jí)數(shù)學(xué)第一學(xué)期期末學(xué)業(yè)水平測試試題含解析
- 20250617國金證券機(jī)器人行業(yè)研究垂直領(lǐng)域具身智能機(jī)器人的野望416mb
- 物理●湖北卷丨2024年湖北省普通高中學(xué)業(yè)水平選擇性考試物理試卷及答案
- 一諾LZYN質(zhì)量流量計(jì)使用說明書-2009版
- 2022年部編版二年級(jí)語文下冊期末試卷(及參考答案)
- 工程項(xiàng)目管理的四控、六管、一協(xié)調(diào)主要內(nèi)容
- 醫(yī)用X射線設(shè)備項(xiàng)目商業(yè)計(jì)劃書范文參考
- 四年級(jí)奧數(shù)講義
評論
0/150
提交評論