数据结构课程设计—文章编辑设计报告.docx
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_05.gif)
《数据结构课程设计—文章编辑设计报告.docx》由会员分享,可在线阅读,更多相关《数据结构课程设计—文章编辑设计报告.docx(17页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、文章编辑一、需求分析功能:输入一页文字,程序可以统计出文字、数字、空格的个数。静态存储一页文章,每行最多不超过80个字符,共N行;要求:(1)分别统计出其中英文字母数和空格数及整篇文章总字数:(2) 统计某一字符串在文章中出现的次数,并输出该次数;(3)删除某一子串,并将 后面的字符前移。存储结构使用线性表,分别用几个子函数实现相应的功能;输入数据的形式和范围:可以输入大写、小写的英文字母、任何数字及标点 符号。输出形式:(1)分行输出用户输入的各行字符;(2)分4行输出全部字母 数、数字个数、空格个数、文章总字数(3)输出删除某一字符串后的文 章;二、概要设计1、定义结构体struct li
2、ne,文本行采用顺序存储;行与行之间采用链式存int count=0;do算总字符数*/(count+=strlen(p-data);)while(p=p-next)!=NULL);return count;/*统计str在文章中出现的次数*/int FindString(LINE * &hcad, char *str)LINE *p=head;int count=0;int h=0;int lenl=0;前行的总字符数*/*计/*遍历链表*/*保存当int len2=strlen(str);串的长度*/int i, j,k;do(lenl=strlen(p-data);*/for(i=0;i
3、datai=strO)k=0;for(j=0;jdatai+j=strj) k+;if (k-len2) count+; i=i+k-l;)/*待统计字符/*当前行的字符数/*字符匹配*/*遍历链while(p=p-next)!=NULL);表*/return count;)/*删除指定的字符审*/void delstringword(char *s,char *str)/* *s为输入的字符串,*str为将要删除的字符*/char *p=strstr(s, str) ;/*从字符串s中寻找str第一次出现的位置*/char trap80;int len=strlen(s);int i=len
4、-strlen(p);int j=i+strlen(str);int count=0;for (int m=0;mi ;m+) tmpcount+=sni;for(int n=j;ndata, str)!=NULL)deistringword(p-data, str);)while(p=p-next) !=NULL);/*遍历链表*/)/*向屏幕输出文章*/voi d OutPut (UNE * &head)LINE *p=head;doprintf (,%sn, p-data);/*遍历while(p=p-next)!=NULL);链表*/)void mainO(LINE *head;Cre
5、ate(head);printf (输入的文章为:n);OutPut(head);printf(n);printf (全部字母数:%d n,z, CountLcttcr (head);printf (数字个数:%d nz/, CountNumber (head);printf (空格个数:%d n,z, CountSpace (head);printf (文章总字数:%d n,z, CountAl 1 (head);char strl20, str220;printf(n);printf (请输入要统计的字符串:);scanf (“%s,strl);printf (%s 出现的次数为:%d n
6、, strl, FindString(head, strl);printf (W);printf(请输入要删除的某一字符串:);scanfstr2);DelString(head, str2);printf (删除$后的文章为:n, str2);Output(head);)四、调试分析:1.测试数据及结果a2、问题思考:输入文章时,计算机怎样识别文章是否结束?输出文章时,怎样处理表示结 束的字符?解决方案:输入文章时,以Clrl+ECE)为结尾,当1叩0=5时,发现输入 *E,则退出输入。输出时文章时,如果tmpstrlen(tmp)T=5即发现表示结束的 字符E,用p-datastrlen(
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 数据结构 课程设计 文章 编辑 设计 报告
![提示](https://www.taowenge.com/images/bang_tan.gif)
限制150内