數(shù)據(jù)結(jié)構(gòu)第二次實(shí)驗(yàn)報(bào)告_第1頁
數(shù)據(jù)結(jié)構(gòu)第二次實(shí)驗(yàn)報(bào)告_第2頁
數(shù)據(jù)結(jié)構(gòu)第二次實(shí)驗(yàn)報(bào)告_第3頁
數(shù)據(jù)結(jié)構(gòu)第二次實(shí)驗(yàn)報(bào)告_第4頁
數(shù)據(jù)結(jié)構(gòu)第二次實(shí)驗(yàn)報(bào)告_第5頁
已閱讀5頁,還剩12頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、 ch=getchar();cout請(qǐng)輸入數(shù)字!n;cout你想到哪一行-countL:ch=getchar();cin.putback(ch);cinpos;MyList:setStart();for(inti=0;inext;returnfence;templatevoidMyList:print()if(cout=0)coutnext;coutLiStringendl;while(fence!=tail);templatevoidMyList:output(char*outputname)ofstreamopf;opf.open(outputname,ios:out);MyList:se

2、tStart();dofence=fence-next;opfLiStringnext;while(fence-next!=tail);fence=fence-next;opfLiString;#endifUtility.h#include#include/standardstringoperations/standardiostreamoperations#include/numericlimits#include/mathematicalfunctions#include/fileinputandoutput#include#include/characterclassification/

3、dateandtimefunction#include/coninputandoutputenumError_codesuccess,fail,underflow,overflow;/enumboolfalse,true;Editor.cpp#includeUtility.h#includeMyList.husingnamespacestd;MyListList;voidgoWhichLine(int&);voiddisplay();voiddelLine();voidinsertLine();voidrepLine();voidfindChar(char*);voidrepChar(char

4、*,char*);voidcount();voidoutput(char*);inttempLine=0;intcountL=0;charinputname20,outputname20;intmain()constintLG=50;voidwhatToDo(char);charinputCh=NULL;Temp:cout輸入目標(biāo)文本名字:;cininputname;coutoutputname;ifstreamipf;ipf.open(inputname,ios:in);if(ipf.fail()cout不能打開文件!n;gotoTemp;return0;charchLG;while(!ip

5、f.eof()ipf.getline(ch,LG-1);List.append(ch);ipf.close();countL=List.length();display();cout你要進(jìn)行什么操作(輸入h獲得幫助):;charchr=getchar();dochr=getchar();if(chr=n)continue;whatToDo(toupper(chr);if(toupper(chr)!=E)cout你要進(jìn)行什么操作(輸入h獲得幫助):;while(toupper(chr)!=E);voidwhatToDo(charch)switch(ch)caseH:coutendl功能符號(hào)表:e

6、ndl;cout輸入Gorg選擇行數(shù)endl;cout輸入Borb顯示緩沖區(qū)中文件endl;cout輸入Dord刪除某一行endl;cout輸入Iori插入某一行endl;cout輸入Rorr替換某一行endl;cout輸入Corc顯示緩沖區(qū)中文件行數(shù)和字符數(shù)endl;cout輸入Forf查找字符串endl;cout輸入Porp替換某個(gè)字符串endl;cout輸入Sors將緩沖區(qū)中文件保存到源文件endl;cout輸入0oro輸出文件endl;cout輸入Eore推出程序。nendl;break;caseG:cout你想到哪一行l(wèi)-countL:;inttemp=0;charch=getcha

7、r();ch=getchar();while(!isdigit(ch)while(ch!=n)ch=getchar();cout請(qǐng)輸入數(shù)字!n;couttemp;goWhichLine(temp);tempLine=temp;break;caseB:display();break;caseD:if(tempLine=0)cout輸入你想刪除的行號(hào)-countL:;inttempin=0;charch=getchar();ch=getchar();while(!isdigit(ch)while(ch!=n)ch=getchar();cout請(qǐng)輸入數(shù)字!n;couttempin;cout被刪除的行

8、:;goWhichLine(tempin);tempLine=tempin;delLine();goWhichLine(tempLine);break;caseI:if(tempLine=0)cout輸入你想插入的行號(hào)-countL:;inttempin=0;charch=getchar();ch=getchar();while(!isdigit(ch)while(ch!=n)ch=getchar();cout請(qǐng)輸入數(shù)字!n;couttempin;goWhichLine(tempin);tempLine=tempin;insertLine();inttempol=tempLine+1;goWh

9、ichLine(tempol);tempLine+;break;caseR:if(tempLine=0)cout輸入你想替換的行號(hào)-countL:inttempin=0;charch=getchar();ch=getchar();while(!isdigit(ch)while(ch!=n)ch=getchar();cout請(qǐng)輸入數(shù)字!n;couttempin;goWhichLine(tempin);tempLine=tempin;repLine();goWhichLine(tempLine);break;caseC:count();break;caseF:if(tempLine=0)cout輸

10、入你查找字符串所在的行號(hào)-countL:;inttempin=0;charch=getchar();ch=getchar();while(!isdigit(ch)while(ch!=n)ch=getchar();cout請(qǐng)輸入數(shù)字!n;couttempin;goWhichLine(tempin);tempLine=tempin;couttemp;goWhichLine(tempLine);findChar(temp);goWhichLine(tempLine);break;caseP:if(tempLine=0)cout輸入你替換字符串所在的行號(hào)-countL:;inttempin=0;cha

11、rch=getchar();ch=getchar();while(!isdigit(ch)while(ch!=n)ch=getchar();couttempin;goWhichLine(tempin);tempLine=tempin;charold20;charne20;coutold;coutendl;coutne;cout替換前:;goWhichLine(tempLine);repChar(old,ne);cout替換后:;goWhichLine(tempLine);break;caseS:output(inputname);break;caseO:output(outputname);b

12、reak;caseE:break;default:cout操作符輸入錯(cuò)誤!n;break;voidgoWhichLine(int&lin)List.fence=List.setPos(lin);coutLinesetw(3)lin:LiStringendl;voiddisplay()List.print();voiddelLine()List.remove();countL-;voidinsertLine()chartemp20;couttemp;List.insert(temp);countL+;voidrepLine()stringtemp;cout輸入想要替換的元素:;cintemp;L

13、ist.replace(temp);voidfindChar(char*ch)inttemp=List.fence-findChar(ch);if(temp=0)cout;for(inti=0;itemp;i+)cout;for(inti=0;i=strlen(ch);i+)cout;coutendl;elsecoutrepSubChar(prch,afch);voidcount()cout行數(shù):List.length()endl;inttemp=0;List.setStart();for(inti=0;inext;temp+=List.fence-LiString.length();cout

14、文本的總字符:tempendl;voidoutput(char*chr)List.output(chr);6.運(yùn)行結(jié)果:a.測(cè)試數(shù)據(jù)選擇:本次測(cè)試選擇了文件名為text.txt的文本文件,輸出文件為out.txt。text.txt文本的內(nèi)容如下:thisisatextbookyoucanuseittodotestthereisnotnewwordcanyoudothetestrightyoucantryjustdoitisthereanywrong對(duì)文件進(jìn)行所列符號(hào)代表的操作,顯示結(jié)果如下:ofinputfile:text.txtoFoutputfile.txthooktodotestnput

15、thenameInputtlienamethisisatextyoucanuseitthereisnotneuuopdcanvau出tliEtestriffhtyaugahtryjustdoititsthereanywrtsng諼作打獲予一行,輸人R-ofinputfile:text.txtoFoutputfile.txthooktodotestnputthenameInputtlienamethisisatextyoucanuseitthereisnotneuuopdcanvau出tliEtestriffhtyaugahtryjustdoititsthereanywrtsng諼作打獲予一行,

16、輸人R-替離pg輸入F查十么操作工斷入h一仃1-?=3ine3:tJiereisnotnewword撤要進(jìn)任什么$輸入辭所要查扌中斐件行數(shù)和字符數(shù)lAo-輸岀文件,輸入E-推岀程序。:gh獲得幫助);fISiLine3=thereisnotneuword4ALine3:t=heieisnotnewwoid你要進(jìn)行什么操作(輸入h獲得幫助).dLine3:canyoudethetestright除要進(jìn)行什么操作輸人b獲得幫助):cb測(cè)試結(jié)果分析:程序能較好的完成任務(wù),由于此程序用單鏈表編寫完成,有些功能的完成與要求有細(xì)微的差別。但此程序能較好的完成文本編輯任務(wù)。7.實(shí)驗(yàn)運(yùn)行情況分析(包括算法、運(yùn)行結(jié)果、運(yùn)行環(huán)境等問題的總體討論):收獲(1)通過編譯和執(zhí)行文本編輯器程序,讓我收獲了文本編輯的知識(shí),同時(shí)通過此過程讓我對(duì)MicrosoftVisualStudio2008更加熟悉了,對(duì)差錯(cuò)也有了更深的了解。(2)在編程過程中遇到了許多問題,比如文件的輸入、輸出等,通過這個(gè)過程的訓(xùn)練,我能更好的利用網(wǎng)上資源,不懂的知道怎么解決。(3)由于大二上學(xué)期數(shù)

溫馨提示

  • 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ì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論