




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、福建農(nóng)林大學(xué)計(jì)算機(jī)與信息學(xué)院計(jì)算機(jī)類課程設(shè)計(jì)報(bào)告課程名稱:JAVA課程設(shè)計(jì)課程設(shè)計(jì)題目:簡易英漢詞典:姓 名系:計(jì)算機(jī)科學(xué)與技術(shù)專 業(yè):計(jì)算機(jī)科學(xué)與技術(shù)年 級(jí):2012學(xué) 號(hào):指導(dǎo)教師:職 稱:年 月 日附件二:課程設(shè)計(jì)結(jié)果評(píng)定格式福建農(nóng)林大學(xué)計(jì)算機(jī)與信息學(xué)院計(jì)算機(jī)類課程設(shè)計(jì)結(jié)果評(píng)定評(píng)語:成績:指導(dǎo)教師簽字:任務(wù)下達(dá)日期:評(píng)定日期: 簡易英漢詞典1. 課程設(shè)計(jì)的目的 本課程設(shè)計(jì)是在Java程序設(shè)計(jì)課程上設(shè)置的,是鞏固學(xué)生所學(xué)理論知識(shí)、培養(yǎng)學(xué)生動(dòng)手能力并使理論與實(shí)際相結(jié)合的重要實(shí)踐環(huán)節(jié)。 本課程設(shè)計(jì)的目的和任務(wù),是通過學(xué)生用Java語言設(shè)計(jì)一個(gè)完整的應(yīng)用程序,使學(xué)生綜合應(yīng)用所學(xué)知識(shí)完成
2、軟件的分析、設(shè)計(jì)、調(diào)試和總結(jié),提高學(xué)生對(duì)Java語言的綜合應(yīng)用能力和解決問題的能力。2. 課程設(shè)計(jì)的要求 學(xué)生可選擇下面題目或者自定題目,但要求具有一定難度和復(fù)雜度,是一個(gè)較為完整的應(yīng)用程序。3. 課程設(shè)計(jì)報(bào)告內(nèi)容3.1 程序代碼4. #include <iostream.h>5. #include <fstream.h>6. #include <stdlib.h>7. #include <string.h>8.9. /using namespace std;10.11. class Word12. private:13. char word20
3、;14. char mean40;15. public:16. Word *lc,*rc;17. Word *next;18. char *getWord()19. return word;20. 21. char *getMean()22. return mean;23. 24. void setWord(char w20)25. strcpy(word,w);26. 27. void setMean(char m40)28. strcpy(mean,m);29. 30. 31. Word(char w20,char m40)32. strcpy(word,w);33. strcpy(mea
4、n,m);34. lc=rc=next=NULL;35. 36. Word(char w20)37. Word(w,"0");38. lc=rc=next=NULL;39. 40. Word()41. Word("0","0");42. lc=rc=next=NULL;43. 44. ;45.46. void istWord(Word *p,Word *nw)47. if (strcmp(nw->getWord(),p->getWord()<0)48. if (!p->lc)49. p->lc=nw;50
5、. 51. else52. istWord(p->lc,nw);53. 54. 55. else56. if (!p->rc)57. p->rc=nw;58. 59. else60. istWord(p->rc,nw);61. 62. 63. return;64. 65.66. bool srcWord(Word *q,char src20)67. bool r;68. if (strcmp(src,q->getWord()<0)69. if(!q->lc)70. return false;71. 72. r=srcWord(q->lc,src)
6、;73. 74. else if (strcmp(src,q->getWord()>0)75. if(!q->rc)76. return false;77. 78. r=srcWord(q->rc,src);79. 80. else81. cout<<"n"<<q->getWord()<<"n"<<q->getMean()<<endl;82. return r;83. 84.85. Word *psrcWord(Word *q,char src20)86. i
7、f (strcmp(src,q->getWord()<0)87. if(!q->lc)88. return NULL;89. 90. psrcWord(q->lc,src);91. 92. else if (strcmp(src,q->getWord()>0)93. if(!q->rc)94. return NULL;95. 96. psrcWord(q->rc,src);97. 98. else99. cout<<"n"<<q->getWord()<<"n"<
8、;<q->getMean()<<endl;100. return q;101. 102.103.104. class WordList105. private:106. Word words;107. public:108. /*loadDic函數(shù),用于加載字典內(nèi)容*/109. void loadDic()110. char temp120,temp240;111. fstream LoadFile;112. LoadFile.open("WordList.dat",ios:in);113. strcpy(temp1,"0");1
9、14. LoadFile>>temp1;115. if (!temp1)116. cout<<"詞典為空!n"117. return;118. 119. words.setWord(temp1);120. LoadFile>>temp2;121. words.setMean(temp2);122. strcpy(temp1,"0");123. LoadFile>>temp1;124.125. while(!LoadFile.eof()126. LoadFile>>temp2;127. Word
10、*newW=new Word(temp1,temp2);128. istWord(&words,newW);129. strcpy(temp1,"0");130. strcpy(temp2,"0");131. LoadFile>>temp1;132. 133. LoadFile.close();134. cout<<"已成功錄入詞典內(nèi)容"<<endl;135. return;136. 137. /*showDic函數(shù),用于查看詞典內(nèi)容*/138. void showDic()139. sys
11、tem("cls");140. Word *q=&words;141. if (words.getWord()="0")142. cout<<"尚未錄入詞典"<<endl;143. return;144. 145. cout<<"NOt"<<"wordt"<<"meaning"<<endl;146. thDic(&words,1);147. cout<<"-The E
12、nd-!"<<endl;148. return;149. 150. /*thDic函數(shù),用于遍歷詞典數(shù)據(jù)*/151. int thDic(Word *p,int i)152. cout<<i<<"t"<<p->getWord()<<"t"<<p->getMean()<<endl;153. if (p->lc) i=thDic(p->lc,i+1);154. if (p->rc) i=thDic(p->rc,i+1);155.
13、return i;156. 157. /*setDic函數(shù),編輯詞典*/158. void setDic()159. int temp;160. while(true)161. system("cls");162. cout<<"請(qǐng)選擇操作:n"163. cout<<"1.修改單詞意思;n"164. cout<<"2.刪除單詞;(不支持)n"165. cout<<"3.新增單詞;(不支持)n"166. cout<<"退出請(qǐng)按
14、0n"167. cin>>temp;168. switch(temp)169. case 1:setWord();system("pause");break;170. case 2:;system("pause");break;171. case 3:;system("pause");break;172. case 0:return;173. default:cout<<"錯(cuò)誤操作!"system("pause");break;174. 175. 176. 17
15、7.178. /*179. /*/180. void setWord()181. char temp20;182. Word *p;183. int i=0;184. system("cls");185. cout<<"請(qǐng)輸入查詢單詞:n"186. cin>>temp;187. p=psrcWord(&words,temp);188. if (!p)189. cout<<"Not found "<<"""<<temp<<&qu
16、ot;" in the list!"<<endl;190. system("pause");191. return;192. 193. cout<<"請(qǐng)輸入"<<p->getWord()<<"的新意思:n"194. cin>>temp;195. p->setMean(temp);196. cout<<"已成功修改"<<p->getWord()<<"的新意思為:n"
17、<<p->getMean()<<endl;197. return;198. 199. /*search函數(shù),使用詞典的查閱功能*/200. void search()201. char temp20;202. int i=0;203. system("cls");204. cout<<"請(qǐng)輸入查詢單詞:n"205. cin>>temp;206. bool r=srcWord(&words,temp);207. if (!r)208. cout<<"Not found &q
18、uot;<<"""<<temp<<"" in the list!"<<endl;209. return;210. 211. ;212.213. void mainFrame()214. int temp;215. WordList dic;216. dic.loadDic();217. while(true)218. system("cls");219. cout<<"-歡迎使用簡易英漢詞典!-"<<endl;220. /c
19、out<<"(!使用前請(qǐng)務(wù)必將詞典內(nèi)容文件拷貝至n"C:SimE2C"下并命名為"WordList.dat")n"221. cout<<"請(qǐng)選擇操作:n"222. cout<<"1.查看詞典內(nèi)容;n"223. cout<<"2.編輯詞典內(nèi)容;n"224. cout<<"3.查詢單詞;n"225. cout<<"退出請(qǐng)按 0n"226. cin>>temp;227. switch(temp)228. case 1:dic.showDic();system("pause");break;229. case 2:dic.setDic();system("pause");break;230. case 3:dic.search();system("pause");break;231. case 0:return;232. default:cout<<"
溫馨提示
- 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 小程序美食活動(dòng)方案
- 巾幗誦讀活動(dòng)方案
- 工會(huì)開展跳繩活動(dòng)方案
- 帆布袋diy活動(dòng)方案
- 就業(yè)招聘活動(dòng)方案
- 居家鍛煉實(shí)踐活動(dòng)方案
- 帶貨主播培訓(xùn)活動(dòng)方案
- 小學(xué)藝術(shù)活動(dòng)活動(dòng)方案
- 少年書畫活動(dòng)方案
- 干眼癥護(hù)眼活動(dòng)方案
- 有機(jī)磷農(nóng)藥中毒(新)課件
- 室性早搏的定位診斷與鑒別共26張課件
- 人防卷材防水層工程檢驗(yàn)批質(zhì)量驗(yàn)收記錄表
- DB11T 716-2019 穿越既有道路設(shè)施工程技術(shù)要求
- 濕式氧化技術(shù)
- T∕CACM 1316-2019 中醫(yī)內(nèi)科臨床診療指南 中風(fēng)后吞咽困難
- 于新華中考專題2018
- 江蘇自考精密加工與特種加工復(fù)習(xí)大全
- 公司發(fā)生火災(zāi)應(yīng)急流程圖
- 數(shù)字電子技術(shù)課程設(shè)計(jì)-數(shù)字秒表(共21頁)
- 幀成形及其傳輸實(shí)驗(yàn)報(bào)告
評(píng)論
0/150
提交評(píng)論