C语言课程设计-行编辑系统.doc

上传人:来看看 文档编号:5014256 上传时间:2020-01-28 格式:DOC 页数:22 大小:103KB
返回 下载 相关 举报
C语言课程设计-行编辑系统.doc_第1页
第1页 / 共22页
C语言课程设计-行编辑系统.doc_第2页
第2页 / 共22页
C语言课程设计-行编辑系统.doc_第3页
第3页 / 共22页
C语言课程设计-行编辑系统.doc_第4页
第4页 / 共22页
C语言课程设计-行编辑系统.doc_第5页
第5页 / 共22页
点击查看更多>>
资源描述

《C语言课程设计-行编辑系统.doc》由会员分享,可在线阅读,更多相关《C语言课程设计-行编辑系统.doc(22页珍藏版)》请在三一文库上搜索。

1、C语言课程设计目 录1、需求分析;2、系统总框图;3、每个模块的设计分析;4、列出所有定义的函数及说明;5、举例说明1、2个比较有特点的算法;6、数据分析。完备性、健壮性等;7、存在的问题与不足及对策;8、使用说明(操作手册);9、学习心得前 言计算机科学技术的发展,不仅极大地促进了整个科学技术的发展,而且明显地加快了经济信息化和社会信息化的进程。因此,计算机教育在全国备受重视,计算机知识与能力已成为21世纪人才素质的基本要素之一。如今,高等教育的计算机教育发展十分迅速。十多年前,只有部分理工科专业开设计算机课程。今天,几乎所有高校的所有专业都开设了程度不同的计算机课程。人们已经认识到,计算机

2、知识已成为当代知识分子知识结构中不可缺少的重要组成部分。而除了掌握计算机的基础知识和操作的基本能力外,掌握一门高级编程语言,并可以熟练运用它,已成为当代大学生综合能力必要组成。计算机技术发展如此迅猛,计算机应用如此广泛,需要学习的东西愈来愈多,而我们的总学时是有限的。一般来说,计算机课程学习可以分为两部分:一部分是理论课程学习,一部分是上机应用实习。根据我们专业的性质和要求,则应侧重于上机操作运用。为此,学校特意在暑期最后一星期安排了32个学时的上机实习。现将一星期的实习内容及结果分析分列如下:简单的行编辑器一 题目要求1 设置一个简单的行编辑器,每行以回车结束。2 数据以文件形式存储。3 编

3、辑器具有查找,替代,修改数据的功能。二 需求分析根据题目要求,数据以文件的形式存储,所以应提供文件的输入,输出等操作;还需要文件具有查找,替换,修改数据的功能。三 总体设计根据上面的需求分析,可以将这个系统的设计分为如下七大模块:编辑,查找,修改,删除,替换,保存,退出。简单的行编辑器系统编辑替换删除修改保存退出查找四 详细设计1 主函数为了各模块的独立性,主函数一般设计得比较简单,本系统主要用主函数打开上次保存的数据和进入主菜单函数流程图main()FILE *fp;fp=fopen(record.txt,w);/*在C:Documents and SettingsAdministrator

4、里建立一个record.txt记事本*/fclose(fp);menu();打开上次保存文件进入主菜单函数程序/*主函数*/2 主菜单函数流程图程序void menu()int w,n;doclrscr();printf(n);printf(tt* * * * * * * * * * * * * * * * * * * * * * * * *n);printf(tt n);printf(tt n);printf(tt Welcome to the magazine order system !_ n);printf(tt n);printf(tt n);printf(tt* * * * * *

5、 * * * * * * * * * * * * * * * * * * *n);printf(nntt *nn);printf(tt 1:add_new_subscribern);printf(tt 2:browsen);printf(tt 3:statisticn);printf(tt 4:exitnn);printf(tt *nn);printf( Choice your number(1-4): bb);scanf(%d,&n);if(n4) w=1;else w=0;while (w=1);/*选择功能*/switch(n) case 1:add();break;/*增加新订户记录*

6、/ case 2:search();break;/*查找过期的订户记录并删除*/ case 3:statistic();break;/*统计*/ case 4:exit();break;/*退出*/ 显示一系列功能选项输入n,判断n是否是0-6根据n的值调用各功能模块函数是否3. 各功能模块函数1)/*添加模块*/void add()int t,i,m;clrscr();t=load_record();printf(How many groups information do you want to add?n);printf(Enter the number: bbb);scanf(%d,&

7、m);for(i=0;im;i+)printf(nInput %dth subscriber record.n,i+1);input(t+i);/*调用输入函数*/save(t+m);/*调用保存函数 保存t+m组数据*/clrscr();/*清屏*/menu();/*返回登陆界面*/void input(int i)printf(Please input:nName sex address phone_number unit_price amount time_ imit n);scanf(%s%s%s%s%s%s%s,&orderi.name,&orderi.sex,&orderi.add

8、r,&orderi.phone_number,&orderi.unit_price,&orderi.amount,&orderi.time_limit);2)/*统计模块*/ statistic()int t;t=load_record();printf(The amount of subscriber is%dbbb,t);printf_n(t);printf(nnnPress any key to go back.nn);getch();menu();void printf_one(int i)/*显示一个仪器记录的函数*/printf(%-10s %-5s %-10s %-11s %-4

9、s %-3s %-10snn,orderi.name,orderi.sex,orderi.addr,orderi.phone_number,orderi.unit_price,orderi.amount,&orderi.time_limit);void printf_n(int n)/*显示n个仪器记录的函数*/int j;clrscr();/*清屏*/printf(Name sex address phone_number price amount time_ imitnn);for(j=0;jn;j+) if(j+1)%10=0)/*控制显示,每屏显示10行*/ printf(nnPass

10、 any key to continue .); getch(); puts(nn); printf_one(j);/*调用显示一个仪器记录的函数*/ 3)/*查询模块*/void search()FILE *fp;char date11,str2;int t,i,sum=0;t=load_record();clrscr();printf(Please input the date: bbbbbbbbbbb);scanf(%s,date);printf(n);if(fp=fopen(record.txt,w)=NULL)/*以只写方式打开*/ printf(nCannot open filen

11、); exit(0); clrscr();printf(n); for(i=0;it;i+) if(strcmp(orderi.time_limit,date)0) sum+; printf(n); printf_one(i);/*把符合条件的记录显示出来*/ printf(nnThe record is out of date!); printf(nnDo you want to delete its information?(YorN): bb); scanf(%s,str); if(strcmp(str,Y)=0|strcmp(str,y)=0) continue; fwrite(&or

12、deri,sizeof(struct magazine),1,fp); fclose(fp); if(sum=0) printf(*nn); printf(Sorry! Cannot find the equipment which you want to.nn); printf(*nn); printf(nnnPress any key to go back the former step.n); getch(); menu();各功能模块查找行删除行 printf(nnnPress any key to go back the former step.n);1 getch();4 )退出模

13、块流程图提示是否保存是否保存保存退出是否程序void myexit(char (*lines)MAXC) char c; printf(Save the lines to the file?(y/n); fflush(stdin); c=getchar(); if(c=n) exit(1); savetofile(lines); exit(1);4 公共函数int load_record()/*加载仪器信息并计算记录仪器个数的函数*/FILE *fp;int i; if(fp=fopen(record.txt,r)=NULL)/*以只读方式打开*/ printf(nCannot open fi

14、len); exit(0); for(i=0;!feof(fp);i+)/*从文件中读入数据并保存在结构体数组中*/fread(&orderi,sizeof(struct magazine),1,fp);fclose(fp);return(i-1);void save(int n)/*n表示保存n组数据,m表示保存在哪个文件夹里*/FILE *fp;int i;fp=fopen(record.txt,w);/*以只写方式打开*/if(fp=NULL)printf(nCannot open filen);exit(0);for(i=0;in;i+) fwrite(&orderi,sizeof(s

15、truct magazine),1,fp); fclose(fp); 综上全程序如下#include#define max 20struct magazinechar name11;char sex6;char addr11;char phone_number12;char unit_price5;char amount4;char time_limit11;ordermax;void save(int n);int load_record();void search();void printf_n(int n);void printf_one(int i);void input(int i)

16、;statitic();void add();void menu();main()FILE *fp;fp=fopen(record.txt,w);/*在C:Documents and SettingsAdministrator里建立一个record.txt记事本*/fclose(fp);menu();void menu()int w,n;doclrscr();printf(n);printf(tt* * * * * * * * * * * * * * * * * * * * * * * * *n);printf(tt n);printf(tt n);printf(tt Welcome to t

17、he magazine order system !_ n);printf(tt n);printf(tt n);printf(tt* * * * * * * * * * * * * * * * * * * * * * * * *n);printf(nntt *nn);printf(tt 1:add_new_subscribern);printf(tt 2:browsen);printf(tt 3:statisticn);printf(tt 4:exitnn);printf(tt *nn);printf( Choice your number(1-4): bb);scanf(%d,&n);if

18、(n4) w=1;else w=0;while (w=1);/*选择功能*/switch(n) case 1:add();break;/*增加新订户记录*/ case 2:search();break;/*查找过期的订户记录并删除*/ case 3:statistic();break;/*统计*/ case 4:exit();break;/*退出*/ /*添加模块*/void add()int t,i,m;clrscr();t=load_record();printf(How many groups information do you want to add?n);printf(Enter

19、the number: bbb);scanf(%d,&m);for(i=0;im;i+)printf(nInput %dth subscriber record.n,i+1);input(t+i);/*调用输入函数*/save(t+m);/*调用保存函数 保存t+m组数据*/clrscr();/*清屏*/menu();/*返回登陆界面*/void input(int i)printf(Please input:nName sex address phone_number unit_price amount time_ imit n);scanf(%s%s%s%s%s%s%s,&orderi.n

20、ame,&orderi.sex,&orderi.addr,&orderi.phone_number,&orderi.unit_price,&orderi.amount,&orderi.time_limit);/*统计模块*/ statistic()int t;t=load_record();printf(The amount of subscriber is%dbbb,t);printf_n(t);printf(nnnPress any key to go back.nn);getch();menu();void printf_one(int i)/*显示一个仪器记录的函数*/printf(%

21、-10s %-5s %-10s %-11s %-4s %-3s %-10snn,orderi.name,orderi.sex,orderi.addr,orderi.phone_number,orderi.unit_price,orderi.amount,&orderi.time_limit);void printf_n(int n)/*显示n个仪器记录的函数*/int j;clrscr();/*清屏*/printf(Name sex address phone_number price amount time_ imitnn);for(j=0;jn;j+) if(j+1)%10=0)/*控制显

22、示,每屏显示10行*/ printf(nnPass any key to continue .); getch(); puts(nn); printf_one(j);/*调用显示一个仪器记录的函数*/ /*查询模块*/void search()FILE *fp;char date11,str2;int t,i,sum=0;t=load_record();clrscr();printf(Please input the date: bbbbbbbbbbb);scanf(%s,date);printf(n);if(fp=fopen(record.txt,w)=NULL)/*以只写方式打开*/ pr

23、intf(nCannot open filen); exit(0); clrscr();printf(n); for(i=0;it;i+) if(strcmp(orderi.time_limit,date)0) sum+; printf(n); printf_one(i);/*把符合条件的记录显示出来*/ printf(nnThe record is out of date!); printf(nnDo you want to delete its information?(YorN): bb); scanf(%s,str); if(strcmp(str,Y)=0|strcmp(str,y)=

24、0) continue; fwrite(&orderi,sizeof(struct magazine),1,fp); fclose(fp); if(sum=0) printf(*nn); printf(Sorry! Cannot find the equipment which you want to.nn); printf(*nn); printf(nnnPress any key to go back the former step.n); getch(); menu();/*公共函数*/int load_record()/*加载仪器信息并计算记录仪器个数的函数*/FILE *fp;int

25、 i; if(fp=fopen(record.txt,r)=NULL)/*以只读方式打开*/ printf(nCannot open filen); exit(0); for(i=0;!feof(fp);i+)/*从文件中读入数据并保存在结构体数组中*/fread(&orderi,sizeof(struct magazine),1,fp);fclose(fp);return(i-1);void save(int n)/*n表示保存n组数据,m表示保存在哪个文件夹里*/FILE *fp;int i;fp=fopen(record.txt,w);/*以只写方式打开*/if(fp=NULL)printf(nCannot open filen);exit(0);for(i=0;in;i+) fwrite(&orderi,sizeof(struct magazine),1,fp); fclose(fp);

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 研究报告 > 商业贸易


经营许可证编号:宁ICP备18001539号-1