ImageVerifierCode 换一换
格式:DOCX , 页数:32 ,大小:83.91KB ,
资源ID:9828453      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bingdoc.com/d-9828453.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(简单行编辑系统数据结构课程设计说明书.docx)为本站会员(b****0)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

简单行编辑系统数据结构课程设计说明书.docx

1、简单行编辑系统数据结构课程设计说明书中北大学数 据 结 构课 程 设 计 说 明 书学 院:电子与计算机科学技术学院专 业:网络工程/计算机科学与技术题 目:简单行编辑器指导教师:潘广贞组长姓名:学号组员姓名:学号组员姓名:学号组员姓名:学号组员姓名:学号2012 年 8月 30 日1. 概述 11.1 设计目的 11.2 设计目标及要求设计要求 11.3 设计进度 11.4 分工 12. 需求分析及总体设计 12.1 数据结构 12.2 功能框架 23功能模块详细设计 23.1设计流程 23.2主要源代码 24功能模块详细设计 24.1设计流程 24.2主要源代码 31. 概述 1.1 设计

2、目的被编辑的文本文件可能很大,全部读入编辑程序的数据空间(内存)的作法既不经济,也不总能实现。所以设计这一种以行为单位进行的编辑程序。主要是逐段地编辑。任何时刻只把待编辑文件的一段放在内存,称为活区。需要用到的数据结构是链表。1.2 设计目标及要求设计要求(1)行插入:格式: i 功能: 在指定行之后插入一行或几行。(2)行删除:格式: d功能: 在指定行之后插入一行或几行。(3)行替换:格式: i功能: 在指定行之后插入一行或几行。(4)活区切换:格式: n功能: 将活区写入文件,并从文件中读入下一段,作为新的活区。(5)活区显示:格式: p功能: 逐页地(每页20行)显示活区内容,每显示一

3、页之后请用户决定是否继续显示以后备页(如果存在)。印出的每一行要前置行号和一个空格符,行号固定占4位,增量为1。(6)模式匹配:格式: k1.3 设计进度12012.8.202012.8.21需求分析22012.8.21下午交需求分析,主要分析课题的内容,需要用的数据结构,小组分工情况32012.8.222012.8.29编写源代码42012.8.30完成设计并书写课程设计说明书52012.8.31 等待老师验收1.4 分工 薛建明 :进行插入功能的编写。 丛 前 :进行删除功能的编写。 甘 炀 :进行活区的切换功能的编写。 杨志文 :进行活区显示,KMP算法,界面的编写。2. 需求分析及总体

4、设计2.1 数据结构 用到数据结构的双向链表: typedef struct text char string80; struct text *next; struct text *pre; int flat; text;2.2 功能框架(1)行插入:在指定行之后插入一行或几行。(2)行删除:在指定行之后插入一行或几行。(3)行替换:在指定行之后插入一行或几行。(4)活区切换: 将活区写入输出文件,并从输入文件中读入下一段,作为新的活区。(5)活区显示:逐页地(每页20行)显示活区内容,每显示一页之后请用户决定是否继续显示以后备页(如果存在)。印出的每一行要前置行号和一个空格符,行号固定占4位

5、,增量为1。(6)模式匹配:在当前活区中查找所要匹配的文本。3功能模块详细设计3.1设计流程 行插入功能:找到要插入的结点对应的指针,然后开辟新的空间,把开辟出的新的空间,与刚才的结点连接,同时再把新节点的指针域只向出入的下一个节点。主要思想: p=(text *)malloc(sizeof(text); / p为新插入节点 p-next=p1-next; / p1为要出入结点的 p-pre=p1; p1-next-pre=p; p1-next=p;3.2主要源代码void insert() int i,j,hang,increhang=1,incre; char s; text *p,*p1

6、,*p2; printf(Note: the i-th row insert text in the i-th row! Inserted text in # Please enter the line number for the end of the flag):n); scanf(%d,&hang); p=p1=NULL; if(hang=0) p=(text *)malloc(sizeof(text); p-flat=1; p-next=head; head-pre=p; head=p; if(hang!=0) for(i=0,p1=head; inext); /找到要插入行的前一行

7、p=(text *)malloc(sizeof(text); /为插入行分配空间 p-flat=1; p-next=p1-next; p-pre=p1; p1-next-pre=p; p1-next=p; /从此行将插入行插入到链表中 p-string0=getchar(); p-string0=getchar(); i=0; incre=1; while(p-stringi!=#) if(incre=80) s=getchar(); if(s=#) i+; p-stringi=s; break; p1=p; p=(text *)malloc(sizeof(text); p-flat=1; p

8、-next=p1-next; p-pre=p1; p1-next-pre=p; p1-next=p; /从此行将插入行插入到链表中 i=0; incre=1; p-stringi=s; i+; incre+; p-stringi=getchar(); p-stringi=n; p-stringi+1=0; puts(Modified text:n); head-flat=1; for(p2=head,j=1; (jnext) /显示出修改后的链表 if(p2-flat=1) printf(line %2d: %s,j,p2-string); if(feof(fp) printf(File ha

9、s ended!);4功能模块详细设计 4.1设计流程 行删除:找到要删除的第一行和要删除的最后一行,分别把他们的指针域记录下 来,把要删除的最后一行之后的文本往前移使的一页达到20行。4.2主要源代码void del() text *p1,*p2,*p3,*p4; int i,j; xiugai=1; printf(the first line and the last lineyou want to delete n); scanf(%d %d,&min,&max); if(head=NULL) printf(n list null! n); p1=p2=head; if(min=1) p

10、1=head; else for(i=0; inext; p3=p1; for(i=0; inext; p4=p2; for(; p4!=NULL; p3=p3-next) /*删除中间节点,将 flat 赋值 0*/ strcpy(p3-string,p4-string); p3-flat=p4-flat; p4=p4-next; for(; p3!=NULL; p3=p3-next) fgets(p3-string,sizeof(p3-string),fp); printf(Modified text:n); for(i=0,j=0,p3=head; inext) if(p3-flat=1

11、) printf(line %2d : %s,j+1,p3-string); j+; 5功能模块详细设计 5.1设计流程 活区切换: 5.2主要源代码void saveshow() int i=0,j=0; char conti=y; text *p=NULL,*p1,*p2,*p3; for(i=0,p=head; (p!=NULL)&(inext) if(p-flat=1) fputs(p-string,out); p3=p1=head; if(p=NULL) for(i=0; iflat=1; p3=p3-next; if(p!=NULL) for(i=0; (p!=NULL)&(ine

12、xt) if(p-flat=1) strcpy(p1-string,p-string); j=j+1; p-flat=0; p1=p1-next; p1-flat=1; if(j20) p2=p1; for(; (jnext) /从文件读入活区 fgets(p2-string,sizeof(p2-string),fp); if(jpre; for(; p2!=NULL;p2=p2-next) p2-flat=0; 6功能模块详细设计6.1设计流程模式匹配 KMP 算法, 编辑函数,用来接受处理编辑命令,活区显示,行替换,活区显示,保存 6.2主要源代码/活区显示void appear() vo

13、id EXIT() ; int i,j; char conti=Y; text *p2; if( !feof(fp) ) page+; printf(*page %d *n,page); for(i=0,p2=head; inext) if(p2-flat=1) printf(line %2d : %s,i+1,p2-string); puts(Should continue to read into it?( Y / N ) :); conti=getchar(); conti=getchar(); if(conti=y|conti=Y) saveshow(); appear(); else

14、 page+; printf(*page %d *n,page); for(i=0,p2=head; inext) if(p2-flat=1) printf(line %2d : %s,i+1,p2-string); puts(nFile has ended!n); /*退出编辑函数后执行的函数,将所有的内容存盘*void saveall() int i; text *p; for(i=0,p=head; inext) /将活区写入文件 if(p-flat=1) fputs(p-string,out); p-flat=0; while(!feof(fp)/将其余的内容写入文件 fputc(fg

15、etc(fp),out);void change() int i,j,hang,incre,inc; char s; text *p,*p1,*p2; xiugai=1; printf(Please input the line number you want to replace (replace text in # is the ending):n); scanf(%d,&hang); p=p1=NULL; if(hang=1) p=head; else for(i=0,p=head; inext); p-string0=getchar(); p-string0=getchar(); p-

16、flat=1; i=0; incre=1; while(p-stringi!=#) i+; incre+; p-stringi=getchar(); if(incre=80) inc+; p-stringi+1=n; p-stringi+2=0; s=getchar(); if(s=#) i+; p-stringi=s; break; p1=p; p=(text *)malloc(sizeof(text); p-flat=1; p-next=p1-next; p-pre=p1; p1-next-pre=p; p1-next=p; i=0; incre=1; p-stringi=s; p-str

17、ingi=n; p-stringi+1=0; puts(Modified text:n); for(p2=head,j=1; (jnext) if(p2-flat=1) printf(line %2d : %s,j,p2-string); if(feof(fp) printf(File has ended!);/*模式匹配 KMP 算法*void KMP() int m=1,next80; int i=0,j=-1; text *p; int a=0,b=0,F=0; char s80,t80; int lens,lent,k; p=head; printf(Please enter the

18、string you want to pattern matching:n); scanf(%s,t); lent=strlen(t); do lens=strlen(p-string); strcpy(s,p-string); next0=-1; while(ilent-1) if(j=-1|ti=tj) +i; +j; nexti=j; else j=nextj; while(alens & b(lent-1) k=a-lent+1; printf(You want to match in the string: line%2d words%d n,m,k); F=1; i=0; j=-1

19、; a=0; b=0; p=p-next; m+; while(m=20); if(F=0) printf(Sorry!Failed to find the string you want to match in the current textn); else printf(Match is ready! !n);void drawmain() /*画主窗口函数*/ int i,j; gotoxy(1,1); /*在文本窗口中设置光标至(1,1)处*/ insline(); /*在文本窗口的(1,1)位置处中插入一个空行*/ gotoxy(20,1); cprintf(%c %c File

20、%c %c,179,17,16,179); /* | |*/ gotoxy(45,1); cprintf(%c %c Edit %c %c,179,17,16,179); /* | |*/ gotoxy(5,25); /*跳至窗口底端*/void drawmenu(int m,int n) /*画菜单,m:第几项菜单,n:第m项的第n个子菜单*/ int i; if(m%2=0) /*画File菜单项*/ window(21,2,32,6); textcolor(0); textbackground(7); for(i=0; i4; i+) /*在上面定义的文本窗口中先输出5个空行*/ got

21、oxy(1,1+i); insline(); window(1,1,80,25); gotoxy(20,1); for(i=1; i=5; i+) gotoxy(21,1+i); cprintf(%c,179); /*窗口内文本的输出函数,在窗口左边输出 | */ gotoxy(32,1+i); cprintf(%c,179); /*窗口内文本的输出函数,在窗口右边输出 | */ for(i=1; i=11; i+) gotoxy(21+i,2); cprintf(%c,196); /*窗口内文本的输出函数,在窗口上边输出 - */ gotoxy(21+i,6); cprintf(%c,196

22、); /*窗口内文本的输出函数,在窗口下边输出 - */ /*以上为显示菜单项的外观*/ textbackground(7); gotoxy(21,2); cprintf(%c,218); /*输出四个边角表格符*/ gotoxy(21,6); cprintf(%c,192); gotoxy(32,2); cprintf(%c,191); gotoxy(32,6); cprintf(%c,217); gotoxy(22,3); cprintf( Open ); gotoxy(22,4); cprintf( Save ); gotoxy(22,5); cprintf( Exit ); textc

23、olor(15); textbackground(0); gotoxy(20,1); cprintf(%c %c File %c %c,179,17,16,179); switch(n%3) case 0: gotoxy(22,3); cprintf( Open ); break; case 1: gotoxy(22,4); cprintf( Save ); break; case 2: gotoxy(22,5); cprintf( Exit ); break; /*/ if(m%2=1) /*画Edit菜单项*/ window(46,2,57,8); textcolor(0); textba

24、ckground(7); for(i=0; i7; i+) gotoxy(1,1+i); insline(); window(1,1,80,25); gotoxy(45,1); for(i=1; i=8; i+) gotoxy(46,1+i); cprintf(%c,179); gotoxy(57,1+i); cprintf(%c,179); for(i=1; i=11; i+) gotoxy(46+i,2); cprintf(%c,196); gotoxy(46+i,9); cprintf(%c,196); textbackground(7); gotoxy(46,2); cprintf(%c,218); gotoxy(46,9); cprintf(%c,192); gotoxy(57,2); cprintf(%c,191); gotoxy(57,9); cprintf(%c,217); gotoxy(47,3); cprintf( del ); gotoxy(47,4); cprintf( insert ); gotoxy(47,5); cprintf( change ); gotoxy(47,6); cprintf( KMP ); gotoxy(47,7); cprintf( saveshow); gotoxy(47,

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2