版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、課程設(shè)計說明書 no.1文章編輯系統(tǒng)1、課程設(shè)計目的(1)較熟練地掌握語言的基本內(nèi)容及程序設(shè)計的基本方法與編程技巧。(2)較熟練地掌握在系統(tǒng)上編輯、編譯、連接和運行c程序的方法。(3)通過設(shè)計一個完整程序,掌握數(shù)據(jù)結(jié)構(gòu)的算法編寫、類c語言算法轉(zhuǎn)換成c程序并上機調(diào)試的基本方法。2、課程設(shè)計方案論證2.1 設(shè)計思路(1)定義結(jié)構(gòu)體 struct line,文本行采用順序存儲,行與行之間采用鏈式存儲文章編輯系統(tǒng)統(tǒng)計字符刪除字符統(tǒng)計文字查找字符圖1:功能模塊圖(2)主要函數(shù):int countnumber(line * &head) /*統(tǒng)計數(shù)字數(shù)*/ 沈 陽 大 學課程設(shè)計說明書 no.2圖2:統(tǒng)計
2、數(shù)字函數(shù)流程圖:開始*p=head,count=0int len=str len(p-data)i=0idatai=48 &p-datainext!p=null結(jié)束nynyn 沈 陽 大 學課程設(shè)計說明書 no.3int findstring(line * &head,char *str) /*統(tǒng)計str在文章中出現(xiàn)的次數(shù)*/開始count=0;h=0;len1=0; len2=strlen(str);p-datai=str0i+k=0;j=0;p-datai+j=strjk+;j+;k=len2count+;i=i+k-1;結(jié)束ynynny圖3:統(tǒng)計str在文章中的出現(xiàn)次數(shù) 沈 陽 大 學課
3、程設(shè)計說明書 no.42.2 源程序清單#include #include typedef struct line char *data; struct line *next;line; void create(line * &head)line *p;printf (請輸入一頁文章,以#為結(jié)尾(每行最多輸入80字符!):n);p=(struct line*)malloc(sizeof(struct line); head=p; char tmp200; for(;1;) gets(tmp); if(strlen(tmp)80) printf(每行最多輸入80字符); break; if(tm
4、p0=35)break; p=p-next=(struct line*)malloc(sizeof(struct line); p-data=(char*)malloc(strlen(tmp); strcpy(p-data,tmp); if(tmpstrlen(tmp)-1=35) p-datastrlen(tmp)-1=0; 沈 陽 大 學課程設(shè)計說明書 no.5 break; p-next=null; head=head-next;int countletter(line * &head) line *p=head; int count=0;do int len=strlen(p-data
5、); for(int i=0;idatai=a&p-dataidatai=a&p-datainext)!=null); return count; int countnumber(line * &head) line *p=head; int count=0; do int len=strlen(p-data); for(int i=0;idatai=48 & p-datainext)!=null); return count;int countspace(line * &head) line *p=head; int count=0; do int len=strlen(p-data); f
6、or(int i=0;idatai=32)count+; while(p=p-next)!=null); return count;/*統(tǒng)計文章的總字數(shù)*/int countall(line * &head) line *p=head; int count=0; do count+=strlen(p-data); while(p=p-next)!=null); return count; 沈 陽 大 學課程設(shè)計說明書 no.7int findstring(line * &head,char *str) line *p=head; int count=0; int h=0; int len1=0
7、; int len2=strlen(str); int i,j,k; do len1=strlen(p-data); for(i=0;idatai=str0)k=0; for(j=0;jdatai+j=strj) k+;if(k=len2)count+;i=i+k-1; while(p=p-next)!=null); return count;void delstringword(char *s,char *str) char *p=strstr(s,str); 沈 陽 大 學課程設(shè)計說明書 no.8char tmp80; int len=strlen(s); int i=len-strlen
8、(p); int j=i+strlen(str); int count=0; for(int m=0;mi;m+)tmpcount+=sm; for(int n=j;ndata,str)!=null)delstringword(p-data,str);while(p=p-next)!=null); void output(line * &head) line *p=head; do printf(%sn,p-data); while(p=p-next)!=null); 沈 陽 大 學課程設(shè)計說明書 no.9void main() int i=0; int operate;line * head
9、;create(head); printf(輸入的文章為:n); output(head); printf(n); printf(全部字母數(shù):%d n,countletter(head); printf(數(shù)字個數(shù):%d n,countnumber(head); printf(空格個數(shù): %d n,countspace(head); printf(文章總字數(shù): %d n,countall(head); char str120,str220; printf(n); printf(*n); printf(* 菜 單 *n); printf(*n); printf(* 1-統(tǒng)計字符串 *n); pri
10、ntf(* 2-刪除字符串 *n); printf(* 0-退出 *n); printf(*n); do printf(請輸入你要選擇的操作: ); scanf(%d,&operate); switch(operate) 沈 陽 大 學課程設(shè)計說明書 no.10case 1: printf(請輸入要統(tǒng)計的字符串:); scanf(%s,&str1);printf(%s出現(xiàn)的次數(shù)為:%d n,str1,findstring(head,str1); printf(n);countall(head); countnumber(head);countletter(head);countspace(he
11、ad); break; case 2: printf(請輸入要刪除的某一字符串:); scanf(%s,&str2); delstring(head,str2);printf(刪除%s后的文章為:n,str2);output(head); break; case 0: ;break; while(operate!=0); 沈 陽 大 學課程設(shè)計說明書 no.113、課程設(shè)計運行結(jié)果與分析圖3:初始界面 沈 陽 大 學課程設(shè)計說明書 no.12圖4:運行界面 沈 陽 大 學課程設(shè)計說明書 no.13輸入1:統(tǒng)計字符數(shù)圖5:統(tǒng)計字符界面 沈 陽 大 學課程設(shè)計說明書 no.14輸入2:刪除字符圖6:刪除字符 沈 陽 大 學課程設(shè)計說明書 no.15輸入0:退出程序圖7:退出程序 沈 陽 大 學課程設(shè)計說明書 no.164、課程設(shè)計體會此次課程設(shè)計使我對數(shù)據(jù)結(jié)構(gòu)方面的知識有了更加深入的了解,也使我認識到自己在學習編程方面還有很多的不足。今后我要多讀一些編程方面的書籍,不能只拘泥于課本上的知識,并注重理論與實踐的結(jié)合,多上機練習編寫程序,提高自己的實際動手能力和獨立思考的能力,不斷充實自己,更好的掌握編程思想。參考文獻1
溫馨提示
- 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. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年隱私權(quán)保護與個人信息處理合作協(xié)議3篇
- 出租車營運證轉(zhuǎn)讓協(xié)議模板
- 商鋪轉(zhuǎn)租協(xié)議書
- 2025年全球及中國生物催化解決方案行業(yè)頭部企業(yè)市場占有率及排名調(diào)研報告
- 2025年全球及中國貓用肝臟功能支持補充劑行業(yè)頭部企業(yè)市場占有率及排名調(diào)研報告
- 2025-2030全球單面撓性覆銅板行業(yè)調(diào)研及趨勢分析報告
- 2025年全球及中國單體液晶行業(yè)頭部企業(yè)市場占有率及排名調(diào)研報告
- 二零二五年度電視節(jié)目嘉賓邀請與參與合同范本4篇
- 2023-2024年項目部安全管理人員安全培訓考試題及答案綜合題
- 2024年崗位安全教育培訓試題含答案(鞏固)
- 小學英語單詞匯總大全打印
- 醫(yī)療廢物集中處置技術(shù)規(guī)范
- 衛(wèi)生健康系統(tǒng)安全生產(chǎn)隱患全面排查
- 媒介社會學備課
- GB/T 15114-2023鋁合金壓鑄件
- 三相分離器原理及操作
- 貨物驗收單表格模板
- 600字A4標準作文紙
- GB/T 18015.2-2007數(shù)字通信用對絞或星絞多芯對稱電纜第2部分:水平層布線電纜分規(guī)范
- 2007年邁騰3.2發(fā)動機維修手冊
- 選擇性必修二課本活動題答案(教參) 高中地理湘教版(2019)選擇性必修二
評論
0/150
提交評論