



下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
廣東工業(yè)大學實驗報告___自動化_學院___網(wǎng)絡工程__專業(yè)_3__班學號_3111001381_姓名__何宇航___成績評定_______教師簽名許亮實驗__八__題目___文學研究助手______________課程名稱數(shù)據(jù)結(jié)構(gòu)APAGE一.實驗目的文學研究人員需要統(tǒng)計某篇英文小說中某些形容詞的出現(xiàn)次數(shù)和位置,試寫出一個實現(xiàn)這一目標的文字統(tǒng)計系統(tǒng),成為“文學研究助手”。二.實驗內(nèi)容英文小說存放在一個文本文件中;帶統(tǒng)計的額詞匯集合要以此輸入完畢,即統(tǒng)計工作必須在程序的以此運行后全部完成;程序的輸出結(jié)果是每個詞的出現(xiàn)次數(shù)和出現(xiàn)位置所在的行號。三.實驗步驟(可選)詳細程序設(shè)計:#include<iostream>#include<string>usingnamespacestd;#include<stdio.h>//包含標準輸入輸出函數(shù)structword{ intline; inttime; word*next;};structwords{ charword_re[20]; intcheck; inttime_t; words*next_s; word*next;};words*input(words*head);//比較并存貯信息時候所用的函數(shù)words*output(words*head);//單純輸出直觀數(shù)據(jù)時所使用的函數(shù)words*input(words*head){intcount=0;intline=0;//記錄行數(shù)所使用的變量inttime_words=0;head->next_s=newwords;intcheck=1;words*insert=newwords;word*insert_word=newword;insert=head->next_s;cout<<"請輸入需要查詢的單詞"<<endl;while(check){ cin>>insert->word_re; insert->time_t=0; insert->check=0; insert->next=newword; cout<<"還希望搜索其他的單詞么,1繼續(xù),0停止"<<endl; cin>>check; if(check>=1) { insert->next_s=newwords; insert=insert->next_s; } } insert->next_s=NULL; insert=head->next_s; while(insert!=NULL) { cout<<insert->word_re<<endl; insert=insert->next_s; } insert=NULL; inttime=0; inttime_gk=0,time_wt=0; charcompare[3]="@"; chargetkey[32]; char*word_tair; FILE*getword; if((getword=fopen("英文文件.txt","r"))==NULL) { cout<<"error"; return0; } charword_c[80]; while(fgets(word_c,80,getword)!=NULL)//讀取一行中的8個字符 { line++; time_words=0;//尋找的字符出現(xiàn)的次數(shù) time_gk=0;//儲存用來比較的字符串所使用的變量 time_wt=0;//在儲存行字符串的變量中定位 word_tair=NULL; word_tair=word_c; time=strlen(word_tair); cout<<time; cout<<word_tair<<endl; while(word_tair[time_wt]!='\n') { time_gk=0; if((word_tair[time_wt]<='z'&&word_tair[time_wt]>='a')||(word_tair[time_wt]<='Z'&&word_tair[time_wt]>='A')||word_tair[time_wt]=='-') { while((word_tair[time_wt]<='z'&&word_tair[time_wt]>='a')||(word_tair[time_wt]<='Z'&&word_tair[time_wt]>='A')||word_tair[time_wt]=='-') { getkey[time_gk]=word_tair[time_wt]; time_wt++; time_gk++; }//讀取出一個單詞,并儲存在新的變量中 getkey[time_gk++]='\0'; insert=head->next_s; while(insert!=NULL) { if(!strcmp(insert->word_re,getkey)) { count=insert->check; insert->check++; insert_word=insert->next;//判斷是否是相同的單詞 while(count>0) { insert_word=insert_word->next; count--; } insert_word->line=line; insert_word->time=time_words; insert_word->next=NULL; insert_word->next=newword; break; }//儲存相應的信息 insert=insert->next_s; } time_words++; } if(word_tair[time_wt++]=='\n') break; } } cout<<endl; returnhead;}//輸出函數(shù)words*output(words*head){ inttime=0; words*first=head->next_s; words*insert=first; word*insert_word=newword; while(insert!=NULL) { cout<<insert->word_re<<"單詞共出現(xiàn)了"<<insert->check<<"次"<<endl; insert_word=insert->next; while(insert->check>time) { time++; cout<<"第"<<time<<"次出現(xiàn)在"<<insert_word->line<<"行,第"<<insert_word->time+1<<"個單詞"<<endl; insert_word=insert_word->next; } insert=insert->next_s; time=0; } returnhead;}intmain(){words*head_emp=newwords;strcpy(head_emp->word_re,"thisisempty");//母鏈的頭賦空head_emp->check=-1;head_emp
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- it耗材采購合同范本
- 勞動服務合同范本
- 包辦野餐服務合同范本
- 農(nóng)業(yè)水費征收合同范本
- 勞務咨詢派遣合同范本
- 東易日盛設(shè)計合同范本
- 兼職領(lǐng)隊合同范本
- 單位內(nèi)部組織合同范本
- 出租鋼管吊籃合同范例
- 企業(yè)貸款借款合同范本
- H3C-CAS虛擬化平臺詳細介紹
- 小學生韻母in、ing常見漢字與區(qū)分練習
- 藥房品種類別及數(shù)量清單
- 機關(guān)檔案管理工作培訓PPT課件
- 初中物理人教版八年級下冊 第1節(jié)牛頓第一定律 課件
- 網(wǎng)站培訓內(nèi)容trswcm65表單選件用戶手冊
- 連續(xù)平壓熱壓機 三篇 俞敏等
- 空調(diào)系統(tǒng)維保記錄表格模板
- 打印版-圓與二次函數(shù)綜合題精練(帶答案)
- 各種閥門CAD圖
- 工程結(jié)算書標準
評論
0/150
提交評論