




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、課程設計說明書 no.1文章編輯系統(tǒng)1、課程設計目的(1)較熟練地掌握語言的基本內(nèi)容及程序設計的基本方法與編程技巧。(2)較熟練地掌握在系統(tǒng)上編輯、編譯、連接和運行c程序的方法。(3)通過設計一個完整程序,掌握數(shù)據(jù)結(jié)構(gòu)的算法編寫、類c語言算法轉(zhuǎn)換成c程序并上機調(diào)試的基本方法。2、課程設計方案論證2.1 設計思路(1)定義結(jié)構(gòu)體 struct line,文本行采用順序存儲,行與行之間采用鏈式存儲文章編輯系統(tǒng)統(tǒng)計字符刪除字符統(tǒng)計文字查找字符圖1:功能模塊圖(2)主要函數(shù):int countnumber(line * &head) /*統(tǒng)計數(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 沈 陽 大 學課程設計說明書 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、程設計說明書 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; 沈 陽 大 學課程設計說明書 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; 沈 陽 大 學課程設計說明書 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); 沈 陽 大 學課程設計說明書 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); 沈 陽 大 學課程設計說明書 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) 沈 陽 大 學課程設計說明書 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); 沈 陽 大 學課程設計說明書 no.113、課程設計運行結(jié)果與分析圖3:初始界面 沈 陽 大 學課程設計說明書 no.12圖4:運行界面 沈 陽 大 學課程設計說明書 no.13輸入1:統(tǒng)計字符數(shù)圖5:統(tǒng)計字符界面 沈 陽 大 學課程設計說明書 no.14輸入2:刪除字符圖6:刪除字符 沈 陽 大 學課程設計說明書 no.15輸入0:退出程序圖7:退出程序 沈 陽 大 學課程設計說明書 no.164、課程設計體會此次課程設計使我對數(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. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 班級自我管理提升計劃
- 急診安全文化建設實踐計劃
- 實驗室安全規(guī)范與培訓計劃
- 學校教學活動安排計劃
- 秘書在團隊溝通中的角色計劃
- 小班三維課程與教育理念實踐計劃
- 2025年美司那項目建議書
- 2025年中國異構(gòu)計算行業(yè)市場運行態(tài)勢及發(fā)展趨勢預測報告-智研咨詢發(fā)布
- 2025年多通道腦電圖機項目建議書
- 淮安市2024-2025學年上學期高一期末考試地理試題(含答案)
- 2025高考數(shù)學一輪復習-第8章-第3節(jié) 圓的方程【課件】
- DB3301T 1088-2018 杭州龍井茶栽培技術(shù)規(guī)范
- 安徽省部分省示范中學2025屆高三第一次模擬考試英語試卷含解析
- 環(huán)保行業(yè)深度研究報告
- 工程機械租賃服務方案及保障措施 (二)
- 部編版初中語文7-9年級教材必背古詩詞、古文99篇詳細解析及欣賞
- 保障性住房補貼委托書范本
- DB36T 1393-2021 生產(chǎn)安全風險分級管控體系建設通則
- 公益捐助活動影響力評估方法
- 國家電網(wǎng)安全培訓
- Unit 1 I go to school by bus. Period 4(說課稿)-2023-2024學年教科版(廣州)英語二年級下冊
評論
0/150
提交評論