![數(shù)據(jù)結(jié)構(gòu)實(shí)訓(xùn)_第1頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-2/9/f1e12b87-7b28-41eb-9ce9-07900cb07632/f1e12b87-7b28-41eb-9ce9-07900cb076321.gif)
![數(shù)據(jù)結(jié)構(gòu)實(shí)訓(xùn)_第2頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-2/9/f1e12b87-7b28-41eb-9ce9-07900cb07632/f1e12b87-7b28-41eb-9ce9-07900cb076322.gif)
![數(shù)據(jù)結(jié)構(gòu)實(shí)訓(xùn)_第3頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-2/9/f1e12b87-7b28-41eb-9ce9-07900cb07632/f1e12b87-7b28-41eb-9ce9-07900cb076323.gif)
![數(shù)據(jù)結(jié)構(gòu)實(shí)訓(xùn)_第4頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-2/9/f1e12b87-7b28-41eb-9ce9-07900cb07632/f1e12b87-7b28-41eb-9ce9-07900cb076324.gif)
![數(shù)據(jù)結(jié)構(gòu)實(shí)訓(xùn)_第5頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-2/9/f1e12b87-7b28-41eb-9ce9-07900cb07632/f1e12b87-7b28-41eb-9ce9-07900cb076325.gif)
版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、高職學(xué)院計(jì)算機(jī)專業(yè)類課 程 設(shè) 計(jì) 報(bào) 告(2012 -2013學(xué)年第1學(xué)期)課程設(shè)計(jì)類型:數(shù)據(jù)結(jié)構(gòu)題目:棧+串+隊(duì)列+線性表+后綴表達(dá)式求值學(xué)號(hào):姓名:專業(yè):計(jì)算機(jī)應(yīng)用技術(shù) 指導(dǎo)教師:課程設(shè)計(jì)日期:2012.高職學(xué)院 制目 錄1. 問(wèn)題分析11.1 問(wèn)題描述11.2 要求分析22. 總體設(shè)計(jì)32.1 功能分析33. 詳細(xì)設(shè)計(jì)43.1 程序結(jié)構(gòu)圖43.2 程序流程圖44. 功能測(cè)試74.1 本系統(tǒng)的主界面74.2 棧子系統(tǒng)界面74.3 串子系統(tǒng)界面104.4 隊(duì)列子系統(tǒng)界面154.5 線性表子系統(tǒng)界面194.6 后綴表達(dá)式求值子系統(tǒng)界面234.7退出系統(tǒng)245. 課程設(shè)計(jì)小結(jié)25參 考 文 獻(xiàn)
2、25附錄:源代碼清單261. 問(wèn)題分析1.1 問(wèn)題描述1. 棧子系統(tǒng)(1) 設(shè)計(jì)一個(gè)字符型的鏈棧。(2) 編寫進(jìn)棧、出棧、顯示棧中全部元素的程序。(3) 編寫一個(gè)把十進(jìn)制整數(shù)轉(zhuǎn)換成二進(jìn)制數(shù)的應(yīng)用程序。(4) 編寫一個(gè)把中綴表達(dá)式轉(zhuǎn)換成后綴表達(dá)式(逆波蘭式)的應(yīng)用程序。(5) 設(shè)計(jì)一個(gè)選擇式菜單,以菜單方式選擇上述操作。2. 串子系統(tǒng)(1) 由用戶通過(guò)鍵盤輸入建立一個(gè)字符串。(2) 編寫插入、刪除、查找、比較、取子字符串、連接字符串、顯示、模式匹配等程序。(3) 設(shè)計(jì)如下所示的選擇式菜單,以菜單方式選擇上述操作。3. 隊(duì)列子系統(tǒng)(1) 掌握隊(duì)列的特點(diǎn)及其描述方法。(2) 用鏈?zhǔn)浇Y(jié)構(gòu)實(shí)現(xiàn)一個(gè)隊(duì)列。
3、(3) 掌握隊(duì)列的各種基本操作。(4) 掌握隊(duì)列的簡(jiǎn)單應(yīng)用程序。4. 線性表子系統(tǒng)(1) 用結(jié)構(gòu)體描述一個(gè)字符型的單項(xiàng)列表。(2) 創(chuàng)建線性表;在線性表中插入元素、刪除元素;顯示線性表中所有元素等基本操作。(3) 用if語(yǔ)句設(shè)計(jì) 一個(gè)選擇式菜單。5. 后綴表達(dá)式求助子系統(tǒng)(1) 后綴表達(dá)式求值子系統(tǒng)。(2) 用鍵盤輸入一個(gè)整數(shù)后綴表達(dá)式(操作數(shù)的范圍是09,運(yùn)算符只含+、*、/、,而且中間不可以有空格),使用循環(huán)程序從左向右讀入表達(dá)式。(3) 如果讀入的是操作數(shù),直接進(jìn)入操作數(shù)棧。(4) 如果讀入的是運(yùn)算符,立即從操作數(shù)棧取出所需的操作數(shù),計(jì)算操作數(shù)運(yùn)算的值,并將計(jì)算結(jié)果存回操作數(shù)棧。(5)
4、檢驗(yàn)程序運(yùn)行結(jié)果。1.2 要求分析1. 棧子系統(tǒng):使用棧的基本算法。2. 串子系統(tǒng):使用串的基本算法。3. 隊(duì)列子系統(tǒng):使用隊(duì)列的基本算法。4. 線性表子系統(tǒng):使用線性表的基本算法。5. 后綴表達(dá)式求值子系統(tǒng):利用棧進(jìn)行計(jì)算2. 總體設(shè)計(jì)2.1 功能分析1. 棧子系統(tǒng)棧的基本操作2. 串子系統(tǒng)串的基本操作3. 隊(duì)列子系統(tǒng)隊(duì)列的基本操作4. 線性表子系統(tǒng)線性表的基本操作5. 后綴表達(dá)式求值子系統(tǒng)對(duì)后綴表達(dá)式進(jìn)行求值3. 詳細(xì)設(shè)計(jì)3.1 程序結(jié)構(gòu)圖主菜單退出后綴表達(dá)式求值子系統(tǒng)線性表子系統(tǒng)棧子系統(tǒng)隊(duì)列子系統(tǒng)串子系統(tǒng)3.2 程序流程圖開(kāi)始鍵盤輸入棧函數(shù)隊(duì)列函數(shù)線性表函數(shù)后綴表達(dá)式求值函數(shù)串函數(shù)選擇退
5、出結(jié)束主函數(shù)流程圖函數(shù)入口進(jìn)棧數(shù)值轉(zhuǎn)換逆波蘭式出棧顯示退出棧函數(shù)流程圖函數(shù)入口連接字串插入字串顯示字串刪除字串取出字串退出比較字串大小輸入字串查找字串串子函數(shù)流程圖函數(shù)入口進(jìn)隊(duì)出隊(duì)讀隊(duì)頭元素顯示退出雙隊(duì)列隊(duì)列子系統(tǒng)函數(shù)流程圖函數(shù)入口建表插入刪除求表長(zhǎng)查找退出顯示線性表子系統(tǒng)函數(shù)流程圖函數(shù)入口鍵盤輸入求值繼續(xù)還是退出?Y結(jié)束N后綴表達(dá)式求值函數(shù)流程圖4. 功能測(cè)試4.1 本系統(tǒng)的主界面4.2 棧子系統(tǒng)界面1. 輸入選項(xiàng)1,進(jìn)入“棧子系統(tǒng)” 2. 輸入選項(xiàng)1,選擇“進(jìn)?!惫δ?. 輸入選項(xiàng)2,選擇“出?!惫δ?. 輸入選項(xiàng)3,選擇“顯示”功能5. 輸入選項(xiàng)4,選擇“數(shù)值轉(zhuǎn)換”功能6. 輸入選項(xiàng)5,
6、選擇“逆波蘭式”功能7. 輸入選項(xiàng)0,選擇“退出”功能4.3 串子系統(tǒng)界面1. 輸入1,進(jìn)入“串子系統(tǒng)”2. 輸入1,選擇“輸入字串”功能3. 輸入2,選擇“連接字串”功能4. 輸入3,選擇“取出字串”功能5. 輸入4,選擇“刪除字串”功能6. 輸入5,選擇“插入字串”功能7. 輸入6,選擇“查找字串”功能8. 輸入7,選擇“比較串大小”功能9. 輸入8,選擇“顯示字串”功能10. 輸入0,選擇“退出”功能4.4 隊(duì)列子系統(tǒng)界面1. 輸入1,進(jìn)入“隊(duì)列子系統(tǒng)”2. 輸入1,選擇“進(jìn)隊(duì)”功能3. 輸入2,選擇“出隊(duì)”功能4. 輸入3,選擇“讀隊(duì)頭元素”功能5. 輸入4,選擇“顯示”功能6. 輸入
7、5,選擇“雙隊(duì)列”功能7. 輸入0,選擇“退出”功能4.5 線性表子系統(tǒng)界面1. 輸入1,進(jìn)入“線性表系統(tǒng)”2. 輸入1,選擇“建表”功能3. 輸入2,選擇“插入”功能4. 輸入3,選擇“刪除”功能5. 輸入4,選擇“顯示”功能6. 輸入5,選擇“查找”功能7. 輸入6,選擇“求表長(zhǎng)”功能8. 輸入0,選擇“退出”功能4.6 后綴表達(dá)式求值子系統(tǒng)界面1. 輸入5,進(jìn)入“后綴表達(dá)式求值子系統(tǒng)”2. 選擇界面4.7退出系統(tǒng)1. 輸入選項(xiàng)0,選擇“退出”功能,此功能下可以退出并關(guān)閉本程序5. 課程設(shè)計(jì)小結(jié)在這次課程設(shè)計(jì)之前總覺(jué)得自己學(xué)的還可以。但通過(guò)這次的課程設(shè)計(jì)讓自己知道了自己有許多不懂的地方和還
8、需要學(xué)習(xí)的知識(shí)點(diǎn)。當(dāng)然在這次課程中也遇到許多的困難尤其是在編完程序后調(diào)試遇到的困難令我難忘。通過(guò)這次課程設(shè)計(jì)也讓我認(rèn)識(shí)到了自己實(shí)踐自己編程、自己調(diào)試的重要性。通過(guò)自己動(dòng)手實(shí)踐不僅可以增強(qiáng)自己自己的動(dòng)手實(shí)踐能力也可以加深自己對(duì)數(shù)據(jù)結(jié)構(gòu)算法的理解。對(duì)我們學(xué)好數(shù)據(jù)結(jié)構(gòu)這門課程具有很大的意義。除此之外我和認(rèn)識(shí)到了和同學(xué)之間的合作的重要性。通過(guò)討論不僅可以融洽同學(xué)之間的關(guān)系也可以更好的得出結(jié)論在調(diào)試中遇到的困難通過(guò)同學(xué)間的討論也可以得到更好的改進(jìn)方法??傊?,這次的課程設(shè)計(jì)讓我受益匪淺也可以增加我對(duì)數(shù)據(jù)結(jié)構(gòu)這門課程設(shè)計(jì)的興趣。讓對(duì)以后數(shù)據(jù)結(jié)構(gòu)的學(xué)習(xí)充滿了信心。參 考 文 獻(xiàn)(1) 李龍澍C+程序設(shè)計(jì)實(shí)訓(xùn)
9、清華大學(xué)出版社,2003年(2) 伍俊良VISUAL C+課程設(shè)計(jì)與系統(tǒng)開(kāi)發(fā)案例,清華大學(xué)出版社2003年(3) 烏尼爾 Visual C+經(jīng)典例程分析中國(guó)電力出版社,2000年(4) 張曜VISUAL C+程序開(kāi)發(fā)案例解析清華大學(xué)出版社,1999年(5) 宋曉宇、王永會(huì)VISUAL C+高級(jí)編程技術(shù)與實(shí)例 中國(guó)水利水電出版社,2003年附錄:源代碼清單/開(kāi)始.cpp#include串.h#include棧.h#include隊(duì)列.h#include線性表.h#include后綴.hvoid main()int choice;char ch;ch=y;while(ch=y|ch=Y)print
10、f(nnn);printf(ntt 數(shù)據(jù)結(jié)構(gòu)主系統(tǒng) );printf(ntt 主菜單 );printf(ntt*);printf(ntt* 1- 棧 *);printf(ntt* 2- 串 *);printf(ntt* 3-隊(duì) 列 *);printf(ntt* 4-線 性 表 *);printf(ntt* 5-自 主實(shí) 驗(yàn) *);printf(ntt* 0-退 出 *);printf(ntt*);printf(ntt 請(qǐng)選擇菜單號(hào)(0-5):);scanf(%d,&choice);getchar();switch(choice)case 1:Stack();break;case 2:Strin
11、g();break;case 3:Queue();break;case 4:LineList();break;case 5:Postfix();break;case 0:ch=n;break;default:printf(菜單選擇錯(cuò)誤!請(qǐng)重輸);system(cls);/棧.cpp#include#include#define STACKMAX 100typedef struct stacknodeint data;struct stacknode *next;StackNode;typedef struct StackNode *top;LinkStack;void Push(LinkSta
12、ck &s,int x)StackNode *p=new StackNode;p-data=x;p-next=s.top;s.top=p;int Pop(LinkStack &s,int &x) StackNode *p;if(s.top!=NULL)p=s.top;x=p-data;s.top=p-next;delete p;return 1;else return 0;void ShowStack(LinkStack s)system(cls);StackNode *p=s.top;if(p=NULL)printf(ntt棧為空.);elseprintf(ntt棧元素為:);while(p
13、!=NULL)printf(%6d,p-data);p=p-next;printf(n);void Conversion(int n)LinkStack s;int x;s.top=NULL;dox=n%2;n=n/2;Push(s,x);while(n);printf(ntt轉(zhuǎn)換后的二進(jìn)制數(shù)值為:);while(Pop(s,x)printf(%d,x);printf(n);void Suffix()system(cls);char strSTACKMAX;char stackSTACKMAX;char expSTACKMAX;char ch;int sum,i,j,t,top=0;print
14、f(ntt輸入算術(shù)表達(dá)式(運(yùn)算符只能包含+,-,*,/),以#結(jié)束:ntt);fflush(stdin);i=0;do i+;scanf(%c,&stri);while(stri!=#&i!=STACKMAX);sum=i;t=1;i=1;ch=stri;i+;while(ch!=#) switch(ch)case (:top+;stacktop=ch;break;case ):while(stacktop!=()expt+=stacktop-;expt+=,;top-;break;case +:case -:while(top!=0 & stacktop!=()expt+=stacktop-
15、;expt+=,;stack+top=ch;break;case *:case /:while(stacktop=*|stacktop=/) expt+=stacktop-; expt+=,;stack+top=ch;break;case :break;default:while(ch=0&ch=z) expt+=ch;ch=stri+;i-;expt+=,;ch=stri+;while(top!=0)expt+=stacktop-;if(top!=0)expt+=,;printf(ntt輸入的中綴表達(dá)式:);for(j=1;jsum;j+)printf(%c,strj);printf(nnt
16、t后綴表達(dá)式:);for(j=1;jt;j+)printf(%c,expj);printf(n);void Stack()system(cls);LinkStack s;int i=1,j=1,val,n;char choice;s.top=NULL;while(1) printf(nnn);printf(ntt 棧子系統(tǒng) );printf(ntt*);printf(ntt* 1-進(jìn) 棧 *);printf(ntt* 2-出 棧 *);printf(ntt* 3-顯 示 *);printf(ntt* 4-數(shù)制轉(zhuǎn)換 *);printf(ntt* 5-逆波蘭式 *);printf(ntt* 0-退
17、 出 *);printf(ntt*);printf(ntt 請(qǐng)選擇菜單號(hào)(0-5):);fflush(stdin);choice=getchar();switch (choice)case 1:while(1)printf(ntt鍵入一個(gè)整數(shù)(0表示結(jié)束)并按回車:);scanf(%d,&val);if(val!=0)Push(s,val);elsesystem(cls);break;break;case 2:if(Pop(s,val)system(cls);printf(ntt出棧元素為:%6dn,val);elsesystem(cls);printf(ntt棧為空,沒(méi)有元素可以出棧!n);
18、break;case 3:ShowStack(s);break;case 4:system(cls);printf(ntt請(qǐng)輸入一個(gè)十進(jìn)制正整數(shù):);scanf(%d,&n);Conversion(n);break;case 5:Suffix();break;case 0:exit(0);break;default:printf(ntt輸入菜單錯(cuò)誤,請(qǐng)重新輸入!n);/串.cpp#include#include#define STRINGMAX 100typedef structchar vecSTRINGMAX;int len;str;void ConcatStr(str *r1,str *
19、r2) int i;printf(nttr1=%s r2=%sn,r1-vec,r2-vec);if(r1-len+r2-lenSTRINGMAX)printf(ntt兩個(gè)串太長(zhǎng),溢出!n);elsefor(i=0;ilen;i+)r1-vecr1-len+i=r2-veci;r1-vecr1-len+i=0;r1-len=r1-len+r2-len;void SubStr(str *r,int i,int j)int k;str a;str *r1=&a;if(i+j-1r-len)printf(ntt子串超界!n);return;elsefor(k=0;kveck=r-veci+k-1;r
20、1-len =j;r1-vecr1-len=0;printf(ntt取出字符為:);puts(r1-vec);void DelStr(str *r,int i,int j)int k;if(i+j-1r-len)printf(ntt所要?jiǎng)h除的子串超界!n);elsefor(k=i+j;klen;k+,i+)r-veci=r-veck;r-len=r-len-j;r-vecr-len=0;str *InsStr(str *r,str *r1,int i)int k;if(i=r-len|r-len+r1-lenSTRINGMAX)printf(ntt不能插入!n);elsefor(k=r-len
21、-1;k=i;k-)r-vecr1-len+k=r-veck; for(k=0;klen;k+)r-veci+k=r1-veck;r-len=r-len+r1-len;r-vecr-len=0;return r;int IndexStr(str *r,str *r1)int i,j,k;for(i=0;r-veci;i+)for(j=i,k=0;r-vecj=r1-veck;j+,k+)if(!r1-veck+1)return i;return -1;int LenStr(str *r)int i=0;while(r-veci!=0)i+;return i;str *CreateStr(str
22、 *r)gets(r-vec);r-len=LenStr(r);return r;int EqualStr(str *r1,str *r2)for(int i=0;r1-veci&r2-veci&r1-veci=r2-veci;i+);return r1-veci-r2-veci;void String()system(cls);str a,b,c,d;str *r=&a,*r1;r-vec0=0;char choice,p;int i,j,ch=1;while(ch!=0)printf(nnn);printf(ntt 串子系統(tǒng) );printf(ntt*);printf(ntt* 1-輸入字
23、串 *);printf(ntt* 2-連接字串 *);printf(ntt* 3-取出字串 *);printf(ntt* 4-刪除字串 *); printf(ntt* 5-插入字串 *); printf(ntt* 6-查找字串 *); printf(ntt* 7-比較串大小 *); printf(ntt* 8-顯示字串 *); printf(ntt* 0-退 出 *); printf(ntt*); printf(ntt 請(qǐng)選擇菜單號(hào)(0-8):); scanf(%c,&choice); getchar();if(choice=1)system(cls);printf(ntt請(qǐng)輸入一個(gè)字符串:)
24、; gets(r-vec); r-len=LenStr(r); else if(choice=2)system(cls);printf(ntt請(qǐng)輸入所要連接的串:); r1=CreateStr(&b); ConcatStr(r,r1); printf(ntt連接以后的新串值為:n); puts(r-vec); else if(choice=3)system(cls);printf(ntt請(qǐng)輸入從第幾個(gè)字符開(kāi)始:); scanf(%d,&i);getchar(); printf(ntt請(qǐng)輸入取出的連續(xù)字符數(shù):); scanf(%d,&j); getchar(); SubStr(r,i,j); e
25、lse if(choice=4)system(cls);printf(ntt請(qǐng)輸入從第幾個(gè)字符開(kāi)始:); scanf(%d,&i);getchar(); printf(ntt請(qǐng)輸入刪除的連續(xù)字符數(shù):); scanf(%d,&j); getchar(); DelStr(r,i-1,j); else if(choice=5)system(cls);printf(ntt請(qǐng)輸入在第幾個(gè)字符前插入:);scanf(%d,&i);getchar();printf(ntt請(qǐng)輸入所要插入的字符串:);r1=CreateStr(&b);InsStr(r,r1,i-1);else if(choice=6)syst
26、em(cls);printf(ntt請(qǐng)輸入所要查找的字符串:);r1=CreateStr(&b);i=IndexStr(r,r1);if(i!=1)printf(ntt第一次出現(xiàn)的位置是第%d個(gè).n,i+1);elseprintf(ntt該子串不在其中!);else if(choice=7)system(cls);printf(ntt請(qǐng)輸入第一個(gè)串:);gets(c.vec);printf(ntt請(qǐng)輸入第二個(gè)串:);gets(d.vec);int k=EqualStr(&c,&d);if(k0)printf(ntt第一個(gè)串大!n);else if(kvec0=0)printf(空!n);els
27、eputs(r-vec);else if(choice=0)exit(0);else printf(nttt請(qǐng)注意!輸入有誤!n);if(choice=!X&choice!=X)printf(ntt按【Enter】鍵繼續(xù),按任意鍵返回主菜單.);p=getchar();if(p!=xA)getchar();break;/隊(duì)列.cpp#includetypedef struct queuenodeint data;struct queuenode *next;QueueNode;typedef structQueueNode *front,*rear;LinkQueue;void InQueue
28、(LinkQueue *q)system(cls);int x;QueueNode *p=new QueueNode;printf(ntt請(qǐng)鍵入一個(gè)整數(shù):);scanf(%d,&x);getchar();p-data=x;p-next=NULL;if(q-front=NULL)q-front=p;else q-rear-next=p;q-rear=p;if(p)printf(ntt%d進(jìn)隊(duì)成功!,x);int OutQueue(LinkQueue *q,int *v)QueueNode *p;if(q-front=NULL)return 0;elsep=q-front;*v=p-data;q-
29、front=p-next;if(q-front=NULL)q-rear=NULL;delete p;return 1;void ShowQueue(LinkQueue *q)system(cls);QueueNode *p=q-front;if(p=NULL)printf(ntt隊(duì)列為空!n);else printf(ntt隊(duì)列中的元素為:);while(p!=NULL)printf(%6d,p-data);p=p-next;printf(n);void ReadFront(LinkQueue *q)system(cls);if(q=NULL|q-front=NULL)printf(ntt隊(duì)列
30、為空!沒(méi)有隊(duì)頂元素!n);elseprintf(ntt隊(duì)首元素是:%4d n,q-front-data);#define QUEUEMAX 20int queueQUEUEMAX;int front=-1;int rear=-1;void InQueue(int val)rear=(rear+)%QUEUEMAX;if(front=rear)printf(ntt隊(duì)列已滿!);elsequeuerear=val;int OutQueue_rear()int t;if(front=rear)return -1;t=queuerear-;if(rear0&front!=-1)rear=QUEUEMA
31、X-1;return t;int OutQueue_front()int t;if(front=rear)return -1;t=queue+front;if(front=QUEUEMAX)front=0;return t;void DQ()system(cls);int choice;int out5;int in5=5,4,3,2,1;int t,pos=0,i;for(i=0;i5;i+)InQueue(ini);printf(ntt初始數(shù)據(jù)順序是:);for(i=0;i5;i+)printf(%d,ini);printf(ntt 1-從頭出隊(duì) 2-從尾出隊(duì)nn);while(front
32、!=rear)printf(tt請(qǐng)輸入選擇(1或2):);scanf(%d,&choice);switch(choice)case 1:t=OutQueue_front();outpos+=t;break;case 2:t=OutQueue_rear();outpos+=t;break;printf(ntt數(shù)據(jù)輸出的順序是:);for(i=0;ifront=q-rear=NULL;while(i)printf(nnn);printf(ntt 隊(duì)列子系統(tǒng) );printf(ntt*);printf(ntt* 1-進(jìn) 隊(duì) *);printf(ntt* 2-出 隊(duì) *);printf(ntt* 3-
33、讀隊(duì)頭元素 *);printf(ntt* 4-顯 示 *);printf(ntt* 5-雙 隊(duì) 列 *);printf(ntt* 0-退 出 *);printf(ntt*);printf(ntt 請(qǐng)選擇菜單號(hào)(0-5):);scanf(%c,&choice);getchar();switch(choice)case 1:InQueue(q);break;case 2:system(cls);if(OutQueue(q,&val)=0)printf(ntt隊(duì)列為空!n);elseprintf(ntt出隊(duì)元素為:%d,val);break;case 3:ReadFront(q);break;cas
34、e 4:ShowQueue(q);break;case 5:DQ();break;case 0:exit(0);break;default:;if(choice=1|choice=2|choice=3|choice=4|choice=5)printf(ntt按【Enter】鍵繼續(xù),按任意鍵返回主菜單,n);w=getchar();if(w!=xA)i=0;system(cls);/線性表.cpp#include#includetypedef struct linknodechar data;struct linknode *next;linnode;linnode *head;int n;vo
35、id createlist()system(cls);n=0;linnode *p,*s;char x;int z=1;head=new linnode;p=head;printf(ntt請(qǐng)逐個(gè)輸入結(jié)點(diǎn),以“x”為結(jié)束標(biāo)記!n);printf(n);while(z)printf(tt輸入一個(gè)字符數(shù)據(jù),并按回車鍵!);scanf(%c,&x);getchar();if(x!=x)s=new linnode;n+;s-data=x;p-next=s;s-next=NULL;p=s;else z=0;void inslist(int i,char x)linnode *s,*p;p=head;int
36、 j=0;while(p!=NULL&jnext;if(p!=NULL)s=new linnode;s-data=x;s-next=p-next;p-next=s;n+;else printf(ntt線性表為空或插入位置超出!n);void dellist(char x)linnode *p,*q;if(head=NULL)printf(ntt線性表已經(jīng)為空!);return;if(head-next=NULL)printf(ntt線性表已經(jīng)為空!);return;q=head;p=head-next;while(p!=NULL&p-data!=x)q=p;p=p-next;if(p!=NUL
37、L)q-next=p-next;delete p;n-;printf(ntt結(jié)點(diǎn)%c已經(jīng)被刪除!,x);else printf(ntt抱歉!沒(méi)有找到您要?jiǎng)h除的結(jié)點(diǎn).);void showlist()system(cls);linnode *p=head;printf(ntt顯示線性表的所有元素:);if(head-next=NULL|p=NULL)printf(ntt鏈表為空!);elseprintf(ntt);while(p-next!=NULL)printf(%5c,p-next-data);p=p-next;void searchlist(char x)linnode *p;int i=1;if(head=NULL)printf(ntt鏈表下隘!);return;if(head-next=NULL)printf(ntt線性表為空,沒(méi)有任何結(jié)點(diǎn)!);return;p=head-next;while(p!=NULL&p-data!=x)p=p-next;i+;if(p!=NULL)printf(ntt在表的第%d位上找到值為%c的結(jié)點(diǎn)!,i,x);elseprintf(ntt抱歉,未找到值為%c的結(jié)點(diǎn)!,x);void LineList()system(cls
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 生產(chǎn)效率提升從流程優(yōu)化到技術(shù)改造
- 2025年度杭州標(biāo)準(zhǔn)房屋租賃租金調(diào)整合同范本
- 現(xiàn)代商業(yè)綜合體的綠色設(shè)計(jì)與節(jié)能策略
- 2025年度人工智能股份分配與產(chǎn)業(yè)發(fā)展合同
- 2025年度國(guó)際貨物多式聯(lián)運(yùn)合同標(biāo)的運(yùn)輸服務(wù)協(xié)議
- 現(xiàn)代辦公環(huán)境下的酒店服務(wù)創(chuàng)新趨勢(shì)
- 現(xiàn)代服務(wù)業(yè)中的用戶體驗(yàn)優(yōu)化策略
- 術(shù)前溝通技巧與患者信息獲取
- 現(xiàn)代商業(yè)中生產(chǎn)計(jì)劃的靈活性與穩(wěn)定性
- 網(wǎng)課學(xué)生的發(fā)言稿(17篇)
- 謝爾塔拉露天煤礦變更環(huán)評(píng)
- 《實(shí)驗(yàn)診斷學(xué)》課件
- 眼的解剖結(jié)構(gòu)與生理功能課件
- 小學(xué)網(wǎng)管的工作總結(jié)
- 2024年銀行考試-興業(yè)銀行筆試參考題庫(kù)含答案
- 診所校驗(yàn)現(xiàn)場(chǎng)審核表
- Q/GDW-1738-2012配電網(wǎng)規(guī)劃設(shè)計(jì)技術(shù)導(dǎo)則
- 【藥用低密度聚乙烯袋探究4500字(論文)】
- 派出所上戶口委托書
- 鄉(xiāng)鎮(zhèn)林長(zhǎng)制培訓(xùn)課件
- 企業(yè)法律顧問(wèn)方案
評(píng)論
0/150
提交評(píng)論