




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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 a
4、nd settingsadministrator里建立一个"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
5、 welcome to the 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:st
6、atisticn");printf("tt 4:exitnn");printf("tt *nn");printf(" choice your number(1-4): bb");scanf("%d",&n);if(n<1|n>4) w=1;else w=0;while (w=1);/*选择功能*/switch(n) case 1:add();break;/*增加新订户记录*/ case 2:search();break;/*查找过期的订户记录并删除*/ case 3:statistic
7、();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",&m);for(i=0;i<m
8、;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
9、ame,&orderi.sex,&orderi.addr,&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();me
10、nu();void printf_one(int i)/*显示一个仪器记录的函数*/printf("%-10s %-5s %-10s %-11s %-4s %-3s %-10snn",,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 p
11、hone_number price amount time_ imitnn");for(j=0;j<n;j+) if(j+1)%10=0)/*控制显示,每屏显示10行*/ printf("nnpass 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();print
12、f("please input the date: bbbbbbbbbbb");scanf("%s",date);printf("n");if(fp=fopen("record.txt","w")=null)/*以只写方式打开*/ printf("ncannot open filen"); exit(0); clrscr();printf("n"); for(i=0;i<t;i+) if(strcmp(orderi.time_limit,date)&
13、lt;0) sum+; printf("n"); printf_one(i);/*把符合条件的记录显示出来*/ printf("nnthe record is out of date!"); printf("nndo you want to delete it's information?('y'or'n'): bb"); scanf("%s",str); if(strcmp(str,"y")=0|strcmp(str,"y")=0)
14、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();各功能模块查找行删除
15、行 printf("nnnpress any key to go back the former step.n");1 getch();4 )退出模块流程图提示是否保存是否保存保存退出是否程序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_reco
16、rd()/*加载仪器信息并计算记录仪器个数的函数*/file *fp;int 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组数据,
17、m表示保存在哪个文件夹里*/file *fp;int i;fp=fopen("record.txt","w");/*以只写方式打开*/if(fp=null)printf("ncannot open filen");exit(0);for(i=0;i<n;i+) fwrite(&orderi,sizeof(struct magazine),1,fp); fclose(fp); 综上全程序如下#include<stdio.h>#define max 20struct magazinechar name11;cha
18、r 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);statitic();void add();void menu();main()file *fp;fp=fopen("record.txt","w"
19、;);/*在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 the m
20、agazine 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");p
21、rintf("tt 4:exitnn");printf("tt *nn");printf(" choice your number(1-4): bb");scanf("%d",&n);if(n<1|n>4) w=1;else w=0;while (w=1);/*选择功能*/switch(n) case 1:add();break;/*增加新订户记录*/ case 2:search();break;/*查找过期的订户记录并删除*/ case 3:statistic();break;/*统计*/ c
22、ase 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 the number: bbb");scanf("%d",&m);for(i=0;i<m;i+)printf("ninput %dth subscriber record.n",i+1);input(t
23、+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.sex,&orderi.addr,&orderi.phone_number,&
24、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("%-10s %-5s %-1
25、0s %-11s %-4s %-3s %-10snn",,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;j<n;j+) if(j+
26、1)%10=0)/*控制显示,每屏显示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",
27、date);printf("n");if(fp=fopen("record.txt","w")=null)/*以只写方式打开*/ printf("ncannot open filen"); exit(0); clrscr();printf("n"); for(i=0;i<t;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 it's information?('y'or'n'): bb"); scanf(&q
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
评论
0/150
提交评论