1、数据结构课程设计文章编辑附录中有全部代码数据结构课程设计文章编辑附录中有全部代码课程设计任务书专业名称:计算机科学与技术(软件工程) 课程名称:数据结构课程设计设计题目:文章编辑问题起止时间: 6 月24 日至 7 月12 日问题描述静态存储一页文章,每行最多不超过80个字符,共N行,程序能够统计出文字、数字、空格的个数,而且能够对文章中特定内容进行查找及替换,同时也能够删除指定内容。基本要求(1)分别统计出其中英文字母数和空格数及整篇文章总字数;(2)统计某一字符串在文章中出现的次数,并输出该次数;(3)查找出文章中某一段文字,并用其它文字进行替换;(4)删除某一子串,并将后面的字符前移。输
2、出形式:(1)分行输出用户输入的各行字符;(2)分4行输出全部字母数、数字个数、空格个数、文章总字数;(3)查找出指定字符串在文章中出现的所有地方并替换,输出替换后结果;(4)输出删除某一字符串后的文章;实现提示 存储结构使用线性表,分别用几个子函数实现相应的功能,而且使用菜单的形式,能够选择所要进行的操作(查找、替换、删除、统计等)。 文章编辑系统1概要设计本次课程设计的题目是文章编辑系统,本系统的功能描述如下:用户新建文本、浏览新建文本、文本字符统计、指定字符串统计、指定字符串删除、指定字符串替换等操作。1. 新建文本2. 浏览输入文本3. 文本字符统计4. 指定字符串统计5. 指定字符串
3、删除6. 指定字符串替换7. 退出系统本系统包含七个功能模块,分别为:新建文本模块,浏览输入文本模块,指定字符串统计模块,指定字符串删除模块,指定字符串删除模块,指定字符串替换模块以退出系统模块。新建文本模块实现用户录入文本信息,而且系统自动保存录入信息。浏览输入文本模块实现了显示用户录入信息的功能。指定字符串统模块实现了对英文字母数和空格数及整篇文章总字数的统计。指定字符串统计实现了统计用户自定义字符串个数的功能。指定字符串删除模块实现了对用户自定义字符串的删除。指定字符串替换模块实现了替换用户自定义字符串为用户定义的新字符功能。退出系统模块实现了退出系统功能。文章编辑系统浏览输入文本新建文
4、本文本字符统计指定字符串删除指定字符串替换指定字符串统计退出系统图1.1 系统功能模块图2详细设计这部分详细介绍了系统中主要部分的功能实现,以及代码功能说明。void Create(LINE * &head) printf (请输入一页文章,以Ctrl+E为结尾(每行最多输入80字符!):n); /以Ctrl+E结束文本录入,避免发生混淆LINE *p=new LINE; /*首先为链表 建立一个附加表头结点*/ head=p; /*将p付给 表头指针*/ char ch100; while(1) gets(ch); /*输入字符串!*/ if(strlen(ch)80) printf(每行最
5、多输入80字符); break; if(ch0=5)break; /*如果发现输入 E,则退出输入*/ p=p-next=new LINE; p-data=new charstrlen(ch)+1; /*为结点分配空间 */ strcpy(p-data,ch); if(chstrlen(ch)-1=5) /*除去最后一个控制符 E */ p-datastrlen(ch)-1=0; break; p-next=NULL; /*最后的一个指针为空 */ head=head-next;/*文本字数统计*/int Count_Space(LINE* &head)/统计空格数 LINE *p=head;
6、 int asc_space=32; int count=0; int i; int Len; do Len=strlen(p-data); for(i=0;idatai=asc_space) count+; while(p=p-next)!=NULL); return count;int Count_Num(LINE * &head)/统计数字个数 LINE *p=head; int count=0; int Len; int i; do Len=strlen(p-data); for(i=0;idatai=48 & p-datainext)!=NULL); return count; in
7、t Count_All_Word(LINE * &head)/统计文章的总字数 LINE *p=head; int count=0; do count+=strlen(p-data); while(p=p-next)!=NULL); return count;int Count_Letter(LINE * &head)/统计字母数 LINE *p=head; int count=0; int Len; int i; do Len=strlen(p-data); for(i=0;idatai=a & p-dataidatai=A & p-datainext)!=NULL); return cou
8、nt;int Find_Word(LINE * &head,char *sch)/统计 sch 在文章中出现的次数 LINE *p=head; int count=0; int len1=0; int len2=strlen(sch); int i,j,k; do len1=strlen(p-data);/当前行的字符数 for(i=0;idatai=sch0) k=0; for(j=0;jdatai+j=schj)k=k+1; if(k=len2) count+;i=i+k-1; while(p=p-next)!=NULL); return count; /*特定字符串的删除*/void d
9、el_string_word(char *s,char *sch) char *p=strstr(s,sch); char tmp80; int len=strlen(s); int k,kk; int i=len-strlen(p); int j=i+strlen(sch); int count=0; for(k=0;ki;k+) tmpcount+=sk; for(kk=j;kkdata,sch)!=NULL) del_string_word(p-data,sch); while(p=p-next)!=NULL);/*特定字符串的替换*/void replace_string_word(c
10、har *s,char *sch,char *reh) int StringLen; char caNewString100; char *FindPos = strstr(s, sch);/ if(!FindPos) | (!sch) / return -1; while(FindPos) memset(caNewString, 0, sizeof(caNewString); StringLen = FindPos - s; strncpy(caNewString, s, StringLen); strcat(caNewString, reh); strcat(caNewString, Fi
11、ndPos + strlen(sch); strcpy(s, caNewString); FindPos = strstr(s, sch); /* return 0; */void Replace_String(LINE * &head,char *sch,char *reh)/替换指定的字符串 LINE *p=head; do while(strstr(p-data,sch)!=NULL) replace_string_word(p-data,sch,reh); while(p=p-next)!=NULL);/*打印输入的文本*/void OutPutTxt(LINE * &head)/向屏
12、幕输出文章 LINE *p=head; printf(文本文件输出如下:); do printf(%sn,p-data); while(p=p-next)!=NULL);void Count(LINE * &head) printf(文章统计信息结果:n); printf(全部字母数:%dn,Count_Letter(head); printf(数字个数:%dn,Count_Num(head); printf(空格个数: %d n,Count_Space(head); printf(文章总字数: %dn,(Count_All_Word(head)+Count_Num(head)+Count_Space(head)+Count_Letter(head)/2); printf(n);void main() LINE *head; char sch20; char reh20; char ID10; char ch; char tmp_sch20; char tmp_rch20;3调试报告在本次程序设计中,在编译过程中,出现了几次问题(1)错误提示:error C2660: search : function does not take 1 parameters 错误类型: Search函数参数错误 改正方法:将
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1