图书信息管理系统实验报告书_第1页
图书信息管理系统实验报告书_第2页
图书信息管理系统实验报告书_第3页
图书信息管理系统实验报告书_第4页
图书信息管理系统实验报告书_第5页
已阅读5页,还剩32页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

课 程 报 告课 程 名 称: 程序设计实践 专 业 班 级 : 信息类1006 学 生 姓 名 : 学 号 : 5 任 课 教 师 : 徐振强 学 期 :2010-2011学年第二学期 课程报告任务书题 目图书信息管理系统主要内容开发一个图书信息管理系统,图书信息包括:图书编号、书名、作者、出版社、类别、出版时间、价格等基本信息(也可以根据自己情况进行扩充,比如是否借出、库存量等)。使之能提供以下基本功能:(1)图书信息录入功能(图书信息用文件保存)输入v(2)图书信息浏览功能输出(3)查询功能(至少一种查询方式)、排序功能(至少一种排序方式): l 按书名查询 按作者名查询 按照价钱排序 按出版时间排序等等(4)图书信息的删除与修改扩展功能:可以按照自己的程度进行扩展。比如(1)简单的权限处理 (2)报表打印功能(3)甚至根据自己情况,可以加上学生信息,并扩充为图书借阅系统。(4)模糊查询 (5)综合查询 (6)统计功能 比如统计处某一类别的图书信息 或 筛选出小于指定数量库存的图书信息等等,总之,可以根据自己需求进行分析功能。任务要求一、提交材料应包括:(1)系统源代码 (2)课程报告二、整个设计过程具体要求(1)需求分析 要求学生对案例系统进行分析,设计出需要完成的功能,完善各个模块的调用关系;(2)设计过程 要求学生进一步明确各模块调用关系,进一步完善模块函数细节(函数名、参数、返回值等)(3)实现过程 要求学生养成良好的编码习惯、完成各个模块并进行测试,最终完成系统整体测试;(4)总结阶段 按照要求完成系统设计和实现报告,并进行总结、答辩。成绩评定报告撰写情况(30分)系统完成情况(30分)答辩情况(40分)总分内容20分规范程度5分程序测试5分基本功能20分扩展功能10分自述情况10分答辩情况30分成绩评定教师:一. 需求分析本次C语言程序设计以“图书馆管理系统”为题,题目要求开发一个图书信息管理系统,图书信息包括:图书编号、书名、作者、出版社、类别、出版时间、价格等基本信息(也可以根据自己的当前能力进行扩充)。基本功能包括:(1)图书信息录入功能(图书信息用文件保存)输入v(2)图书信息浏览功能输出(3)查询功能(至少一种查询方式)、排序功能(至少一种排序方式): l 按书名查询 按作者名查询 按照价钱排序 按出版时间排序等等(4)图书信息的删除与修改当然,也可以根据个人的情况进行适当的扩展:比如权限处理啊,报表打印功能,模糊查询,统计功能,或 筛选出小于指定数量库存的图书等等。测试数据有ASCII文件tushu_list.txt提供:tushu_list.txt文件结构:(无序)图书编号 书名 作者 出版社 类别 出版社时间 价格-1001 三国演义 罗贯中 民族文学出版社 小说 1585 55.51008 孟子 孟子 人民教育出版社 古籍 1981 23.331002 水浒传 施耐庵 民族文学出版社 小说 1582 48.361003 西游记 吴承恩 民族文学出版社 小说 1602 46.381006 线性代数 同济 同济大学出版社 教育 2010 19.981010 新视野 郑树棠 外研社 教育 2009 32.901007 春秋 孔子 人民教育出版社 古籍 1980 22.221009 时间简史 霍金 外研社 科普 1977 35.311004 红楼梦 曹雪芹 民族文学出版社 小说 1621 49.591005 高等数学 同济 同济大学出版 教育 2010 29.6二概要设计(1).数据结构根据题目给定的图书信息和数据格式可知道,链表结点必须用结构体实现。故:首先建立结构体数组:struct tushuchar num10; 字符型图书编号char name20; 字符型书名char writer20; 字符型作者char press20; 字符型出版社char kind20; 字符型类别double time; 双精度实型出版时间double price; 实型价格struct tushu *next; 用与构建连表指向下一结点;FILE *fp; 定义全局变量fp(2).模块划分定义全局变量:FILE *fp; /* 定义全局变量fp*/函数原型清单:/*密码验证*/void secret(); /*主菜单*/void menu(); /*录入图书信息*/struct tushu * Input();/*将信息导入文件可追加*/void fprint(struct tushu *head); /*将信息导入文件只写(可覆盖)*/void fprint_(struct tushu *head);/*从tushu_list中读取数据构建链表*/struct tushu * create(struct tushu * head,int *n); /*浏览全部图书信息*/ void Browse(struct tushu *head);/*统计图书数目*/void count(struct tushu *head);/*按书名查询图书*/void Findofname(struct tushu *head);/*按作者查询图书*/void Findofwriter(struct tushu *head);/*按类别查询图书*/void Findofkind(struct tushu *head); /*按出版时间排序*/void Sort_time(struct tushu * head); /*按价格排序*/void Sort_price(struct tushu * head);/*按图书编号排序*/void Sort_num(struct tushu * head);/*按编号删除图书*/struct tushu * Delete(struct tushu * head,char m15);/*修改图书*/struct tushu * Revise(struct tushu *head);(3).程序总体框架模块层次结构只确定了模块之间的关系以及函数原型,不是程序的执行步骤。程序的总体框架是程序的总体流程图。此程序并非是按照顺序逐一执行的,其中有某些程序他们之间的关系并不是递进,而是并列。所以选取一个合适的菜单是最佳方案。程序的总体框架如下:由主函数进入程序密码验证通过后输出主菜单 图书馆图书管理系统 0-退出系统 6-按类别查询 1-添加新图书 7-按时间排序 2-浏览图书 8-按价格排序 3-统计图书数目 9-按编号排序 4-按书名查询 10-按编号删除图书5-按作者查询 11-修改图书 未通过输入对应编号0-退出系统1-添加新图书2-浏览图书3-统计图书数目4-按书名查询5-按作者查询6-按类别查询7-按时间排序8-按价格排序9-按编号排序10-按编号删除图书11-修改图书三.功能模块的详细设计主菜单1.函数原型,功能及形参说明函数原型:void menu()函数功能:实现系统的菜单调用,显示对应选项参数说明:函数类型为空2.程序清单void menu() printf(n*n);printf( 图书馆图书管理系统 n);printf(-n);printf( 0-退出系统 6-按类别查询 n);printf( 1-添加新图书 7-按时间排序 n);printf( 2-浏览图书 8-按价格排序 n);printf( 3-统计图书数目 9-按编号排序 n);printf( 4-按书名查询 10-按编号删除图书 n);printf( 5-按作者查询 11-修改图书 n);printf(-n);printf(_ n);密码验证1.函数原型,功能及形参说明函数原型:void secret()函数功能:实现系统的密码验证功能参数说明: char a20 20个字符以内的密码输入 system(cls); 库函数 清频2.程序清单void secret()char a20;printf(*进入图书管理系统前请先进行密码验证-);dogets(a); /*输入密码*/system(cls); /*调用库函数清屏*/printf(对不起!您输入的密码有误,请重新输入-);while(strcmp(a,0605)!=0); /*单一密码“0605”*/system(cls);printf( 欢迎进入图书管理系统n);添加新图书及是否保存1.函数原型,功能及形参说明函数原型:struct tushu * Input()函数功能:实现图书的添加及保存(其中调用函数void fprint(struct tushu *head);/*将信息导入文件可追加*/)参数说明:*head 链表头结点指针 *p1,*p2 辅助结点 局外变量2.程序清单/*录入图书信息建立图书信息的链表*/struct tushu * Input()struct tushu *p1,*p2,*head; /*建立辅助结点及头结点*/char num;int n=0,x;system(cls);menu();printf(n请按对应项输入图书信息以#结束:n);p1=(struct tushu *)malloc(sizeof(struct tushu);head=p2=p1;do /*使用do while语句输入图书信息*/scanf(%s,&p1-num);if(strcmp(p1-num,#)=0)break; /*判断结束符*/elsescanf(%s%s%s%s%lf%lf,p1-name,p1-writer,p1-press,p1-kind,&p1-time,&p1-price);num=#; /*?*/p1=(struct tushu *)malloc(sizeof(struct tushu);p2-next=p1;p2=p1;n+;while(1);p1-next=NULL;printf(图书信息输入结束!n);getchar(); printf(是否保存图书信息?(1.是/2.否):);scanf(%d,&x);if(x=1)fprint(head); /*调用函数保存至文件*/elseprintf(n文件没有被保存!n);return head; /*返回头指针*/将信息导入文件可追加1.函数原型,功能及形参说明函数原型:void fprint(struct tushu *head)函数功能:实现图书的保存将信息导入文件可追加参数说明:struct tushu *head 链表头结点指针2.程序清单void fprint(struct tushu *head)struct tushu *p1;if(fp=fopen(tushu_list.txt,a)=NULL)printf(File open error!n);exit(0);for(p1=head;p1-next!=NULL;p1=p1-next) /*遍历*/fprintf(fp,%st%st%st%st%st%.0lft%lfn,p1-num,p1-name,p1-writer,p1-press,p1-kind,p1-time,p1-price);/*将图书信息写入文件*/fclose(fp); /*关闭文件*/system(cls);menu();printf(n图书信息已成功保存到文件 tushu_list.txt 中!n);getchar();将信息导入文件不可追加1.函数原型,功能及形参说明函数原型:void fprint_(struct tushu *head)函数功能:实现修改及删除后的图书保存将信息导入文件并覆盖原文件参数说明:struct tushu *head 链表头结点指针2.程序清单void fprint_(struct tushu *head)struct tushu *p1;if(fp=fopen(tushu_list.txt,w)=NULL)printf(File open error!n);exit(0);for(p1=head;p1!=NULL;p1=p1-next) /*遍历*/fprintf(fp,%st%st%st%st%st%.0lft%lfn,p1-num,p1-name,p1-writer,p1-press,p1-kind,p1-time,p1-price);/*将图书信息写入文件*/fclose(fp); /*关闭文件*/system(cls);menu();printf(n图书信息已成功保存到文件 tushu_list.txt 中!n);getchar();浏览图书信息1.函数原型,功能及形参说明函数原型:void Browse(struct tushu *head)函数功能:实现图书信息的输出 参数说明:struct tushu *head 链表头结点指针2.程序清单void Browse(struct tushu *head) /*浏览全部图书信息*/char num10;char name20;char writer20;char press20;char kind20;double time;double price;system(cls);menu();if(fp=fopen(tushu_list.txt,a+)=NULL)printf(File open error!n);exit(0);printf(-n);printf(编号 书名 作者 出版社 类别 出版时间 价格n);while(!feof(fp)/*读取并输出*/fscanf(fp,%s%s%s%s%s%lf%lf,num,name,writer,press,kind,&time,&price); printf( %st%st%st%st%st%.0lft%.2lfn,num,name,writer,press,kind,time,price);if(fclose(fp)printf(Can not close the file!n);exit(0);从tushu_list中读取数据构建链表1.函数原型,功能及形参说明函数原型:struct tushu * create(struct tushu * head,int *n)函数功能:建立图书信息单向链表参数说明:struct tushu *head 链表头结点指针 int *n 图书数目指针2.程序清单struct tushu * create(struct tushu * head,int *n)struct tushu *p,*p1,*p2;if(fp=fopen(tushu_list.txt,a+)=NULL)/*先安全打开目录文件*/printf(File open error!n);exit(0);while(!feof(fp)/*读取并创建链表*/(*n)+;p=(struct tushu *)malloc(sizeof(struct tushu);fscanf(fp,%s%s%s%s%s%lf%lf,p-num,p-name,p-writer,p-press,p-kind,&p-time,&p-price);if(head=NULL)head=p;p1=p;elsep1-next=p;p2=p1;p1=p;p2-next=NULL;free(p); /*释放辅助结点所占用空间*/(*n)-;fclose(fp);return head;统计图书数目1.函数原型,功能及形参说明函数原型:void count(struct tushu *head)函数功能:实现图书信息数目统计并输出 参数说明:struct tushu *head 链表头结点指针 n 计数2.程序清单void count(struct tushu *head) /*统计图书数目*/int n=0;struct tushu *p1;head=create(head,&n); /*调用创建链表函数*/for(p1=head;p1-next!=NULL;p1=p1-next) /*遍历*/n+; /*计数*/printf(n此系统统计在内的图书共有 %d 册。n,(n+1)/2);/*计算并输出图书数目*/按书名查询图书信息1.函数原型,功能及形参说明函数原型:void Findofname(struct tushu *head)函数功能:实现图书信息按照书名查询并输出 参数说明:struct tushu *head 链表头结点指针 i 计数判定char b20; 查找编号2.函数流程图Findofnamei=0;输入目标图书名称10bstrcmp(p-name,b)head!=NULL遍历未找到p=p-nexti!=0输出图书信息i+=0;=0!=03.程序清单void Findofname(struct tushu *head) /*按书名查询图书*/int i=0,n; /*i为计数判定*/char b20; /*定义查找编号*/struct tushu *p;head=create(head,&n);p=head;system(cls);menu();printf(n请输入要查询的图书名称:);scanf(%s,b);while(p!=NULL)if(strcmp(p-name,b)=0) /*比较输入的字符串与原文件中书名*/printf(n编号 书名 作者 出版社 类别 出版时间 价格n);printf(%st%st%st%st%st%.0lft%.2lf n,p-num,p-name,p-writer,p-press,p-kind,p-time,p-price);i+;p=p-next;if(i=0)printf(n对不起!没有找到名为%s的图书!n,b);按作者查询图书1.函数原型,功能及形参说明函数原型:void Findofwriter(struct tushu *head)函数功能:实现图书信息按照图书作者查询并输出 参数说明:struct tushu *head 链表头结点指针2.程序清单void Findofwriter(struct tushu *head)int i=0,n;char b20;struct tushu *p;head=create(head,&n);p=head;system(cls);menu();printf(n请输入要查询的图书作者姓名:);scanf(%s,b);while(p!=NULL)if(strcmp(p-writer,b)=0)printf(n编号 书名 作者 出版社 类别 出版时间 价格n);printf(%st%st%st%st%st%.0lft%.2lf n,p-num,p-name,p-writer,p-press,p-kind,p-time,p-price);i+;p=p-next;if(i=0)printf(n对不起!没有找到 %s 所著的相关图书!n,b);按类别查询图书1.函数原型,功能及形参说明函数原型:void Findofkind(struct tushu *head)函数功能:实现图书信息按照图书类别查询并输出 参数说明:struct tushu *head 链表头结点指针2.程序清单void Findofkind(struct tushu *head)int i=0,n;char b20;struct tushu *p;head=create(head,&n);p=head;system(cls);menu();printf(n请输入您要查询的图书类别:);scanf(%s,b);while(p!=NULL)if(strcmp(p-kind,b)=0)printf(n编号 书名 作者 出版社 类别 出版时间 价格n);printf(%st%st%st%st%st%.0lft%.2lf n,p-num,p-name,p-writer,p-press,p-kind,p-time,p-price);i+;p=p-next;if(i=0)printf(n对不起!没有找到类别为 %s 的图书!n,b);按出版时间排序1.函数原型,功能及形参说明函数原型:void Sort_time(struct tushu * head)函数功能:实现图书信息按照出版时间并输出 ,但此过程并不被储存至文件参数说明:struct tushu *head 链表头结点指针 struct tushu *p,*tail; 定义辅助变量用于选择排序2.程序清单void Sort_time(struct tushu * head)struct tushu *p,*tail; /*定义中间变量*/ double time;int n;p=(struct tushu *)malloc(sizeof(struct tushu);/*分配动态空间*/system(cls);menu();head=create(head,&n);while(head-next!=NULL) /*利用选择法排序*/tail=NULL; p=head; time=p-time; /*将链表中第一个时间赋给time*/ while(p!=NULL)if(p-time)time; /*交换*/tail=p; p=p-next;tail=NULL;p=head;while(p-next!=NULL)if(p-time=time)printf( %st%st%st%st%st%.0lft%.2lf n,p-num,p-name,p-writer,p-press,p-kind,p-time,p-price);if(p=head)head=head-next;elsetail-next=p-next;tail=p;p=p-next;if(p-time=time) /*价格相同时无需比较*/printf( %st%st%st%st%st%.0lft%.2lf n,p-num,p-name,p-writer,p-press,p-kind,p-time,p-price);tail-next=NULL;p=head; /*将链表赋给结构体指针*/printf( %st%st%st%st%st%.0lft%.2lf n,p-num,p-name,p-writer,p-press,p-kind,p-time,p-price);/*浏览排序后的信息*/printf(按价格成功排序后输出如上(注:此过程不保存至文件):n);return;按价格排序1.函数原型,功能及形参说明函数原型:void Sort_price(struct tushu * head)函数功能:实现图书信息按价格排序并输出 ,但此过程并不被储存至文件参数说明:struct tushu *head 链表头结点指针 struct tushu *p,*tail; 定义辅助变量用于选择排序2.程序清单void Sort_price(struct tushu * head)struct tushu *p,*tail; /*定义中间变量*/ double price;int n;p=(struct tushu *)malloc(sizeof(struct tushu);system(cls);menu();head=create(head,&n);while(head-next!=NULL) /*利用选择法排序*/tail=NULL; p=head; price=p-price; /*将链表中第一个价格赋给price*/ while(p!=NULL)if(p-price)price;tail=p; p=p-next;tail=NULL;p=head;while(p-next!=NULL)if(p-price=price)printf( %st%st%st%st%st%.0lft%.2lf n,p-num,p-name,p-writer,p-press,p-kind,p-time,p-price);if(p=head)head=head-next;elsetail-next=p-next;tail=p;p=p-next;if(p-price=price) /*价格相同时无需比较*/printf( %st%st%st%st%st%.0lft%.2lf n,p-num,p-name,p-writer,p-press,p-kind,p-time,p-price);tail-next=NULL;p=head; /*将链表赋给结构体指针*/printf( %st%st%st%st%st%.0lft%.2lf n,p-num,p-name,p-writer,p-press,p-kind,p-time,p-price);/*浏览排序后的信息*/printf(按价格成功排序后输出如上(注:此过程不保存至文件):n);return;按图书编号排序1.函数原型,功能及形参说明函数原型:void Sort_num(struct tushu * head)函数功能:实现图书信息按图书编号排序并输出 ,但此过程并不被储存至文件参数说明:struct tushu *head 链表头结点指针 struct tushu *p,*tail; 定义辅助变量用于选择排序2.程序清单void Sort_num(struct tushu * head)struct tushu *p,*tail; char num20;int n;p=(struct tushu *)malloc(sizeof(struct tushu);system(cls);menu();head=create(head,&n);while(head-next!=NULL)tail=NULL; p=head; strcpy(num,p-num); while(p!=NULL)if(strcmp(p-num,num)num);tail=p; p=p-next;tail=NULL;p=head;while(p-next!=NULL)if(strcmp(p-num,num)=0)printf( %st%st%st%st%st%.0lft%.2lf n,p-num,p-name,p-writer,p-press,p-kind,p-time,p-price);if(p=head)head=head-next;elsetail-next=p-next;tail=p;p=p-next;fprint_(head);按编号删除图书1.函数原型,功能及形参说明函数原型:struct tushu * Delete(struct tushu * head,char m15)函数功能:实现图书信息按图书编号删除 ,并将删除后的信息储存至文件参数说明:struct tushu *head 链表头结点指针 struct tushu *ptr1,*ptr2; 定义辅助变量char m15 用于储存欲删除的图书编号2.程序流程图输入要删除的图书编号strcmp(head-num,m)=0strcmp(head-num,m)!=0ptr1=head;ptr2=head-next;ptr2=head;head=head-next;free(ptr2);ptr1=ptr2;ptr2=ptr1-next;已删除并保存至文件Delete(head,m);Head!=NULL无图书P2!=NULLstrcmp(ptr2-num,m)ptr1-next=ptr2-next;free(ptr2);=0!=0fprint_(head);Head=NULL3.程序清单struct tushu * Delete(struct tushu * head,char m15)struct tushu *ptr1,*ptr2;int n;system(cls);menu();printf(n请输入想要删除的图书编号:);scanf(%s,m);head=create(head,&n);while(strcmp(head-num,m)=0)&head!=NULL)ptr2=head;head=head-next;free(ptr2);if(head=NULL)printf(无图书信息!n);return head;ptr1=head;ptr2=head-next;while(ptr2!=NULL)if(strcmp(ptr2-num,m)=0)ptr1-next=ptr2-next;free(ptr2);elseptr1=ptr2;ptr2=ptr1-next;fprint_(head);system(cls);menu();printf(n编号为 %s 目标图书已被删除,并保存至文件!n,m);return head;修改图书信息1.函数原型,功能及形参说明函数原型:struct tushu * Revise(struct tushu *head)函数功能:以编号查找目标图书实现图书信息的各个成分的修改 ,并将修改后的信息储存至文件参数说明:struct tushu *head 链表头结点指针 struct tushu *ptr1,*ptr2; 定义辅助变量char a10 用于储存欲修改的图书编号2.程序清单struct tushu * Revise(struct tushu *head)int n,k;char a10; char num10; /*图书编号*/char name20; /*书名*/char writer20; /*作者*/char press20; /*出版社*/char kind20; /*类别*/double time; /*出版时间*/double price; /*价格*/struct tushu *p;system(cls);menu();head=create(head,&n);p=head;printf(n所有的图书信息如下:n);Browse(head);printf(请选择您要修改的图书的编号:);scanf(%s,a);system(cls);while(p!=NULL)if(strcmp(p-num,a)=0)system(cls);printf(n*n); printf(1-修改图书编号 2-修改图书名称 n); printf(3-修改图书作 4-修改图书出版社 n); printf(5-修改图书类别 6-修改图书出版时间 n); printf(7-修改图书价格 0-停止修改 n); printf(*n); printf(n您要修改的图书基本信息如下:n);printf(编号 书名 作者 出版社 类别 出版时间 价格n);printf(%st%st%st%st%st%.0lft%.2lf n,p-num,p-name,p-writer,p-press,p-kind,p-time,p-price);while(1)printf(请按0-7选择需要修改的图书成分:);scanf(%d,&k);switch(k)case 1:printf(请输入新的图书编号:n);scanf(%s,num);strcpy(p-num,num);break;case 2:printf(请输入新的图书名称:n);scanf(%s,name);strcpy(p-name,name);break;case 3:printf(请输入新的图书

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论