C语言图书管理系统课程设计报告(共19页)_第1页
C语言图书管理系统课程设计报告(共19页)_第2页
C语言图书管理系统课程设计报告(共19页)_第3页
C语言图书管理系统课程设计报告(共19页)_第4页
C语言图书管理系统课程设计报告(共19页)_第5页
已阅读5页,还剩14页未读 继续免费阅读

下载本文档

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

文档简介

1、精选优质文档-倾情为你奉上第三章 图书管理系统的设计与实现3.1系统的需求分析图书登记管理系统作为一个应用软件将为学校的老师和学生提供一个对学校图书馆深入了解并借阅、还书的平台。根据系统界面的提示信息对图书馆信息进行查询、初始化等操作系统功能需求分析描述如下: (1)系统主菜单:进入系统和退出系统 (2)功能菜单:显示可以进行的操作(3)查询主菜单:根据图书编号、书名、作者进行查询,并可显示所有图书信息(4)借还书主菜单:可以进行借书和还书等操作3.2系统的设计3.2.1 系统的总统设计 下面从系统的整体流程的功能模块、系统界面及数据结构进行总体设计。 (1)总体思想 本系统主要设计思想是实现

2、图书馆的功能机管理系统信息的查询、借书、还书等主要功能。系统的设计方法是结构化实际方法,系统用C语言进行开发用户可以清晰的了解图书馆内的情况。 (2)系统模块结构图 根据需求分析结果,图书管理系统可以分为三大模块:查询图书模块、借书功能模块、还书功能模块。系统模块结构如图: 图书管理系统还书功能系统借书功能系统图书管理主菜单图书查询系统3.2.2 系统的概要设计 系统主菜单。 显示系统的主菜单,里面有相应的功能代码,根据选择各功能代码进入不同的界面。功能主要包括:退出系统、查询图书、借书、还书。 查询图书信息 进入此菜单功能模块,输入您要查询的图书的编号、名字、作者等。图书查询模块流程如图:开

3、始 提示输入图书编号、书名、作者输入正确查询 否 是 重新输入 是退出系统 否3.3 测试结果系统主界面功能菜单查询系统菜单借还系统菜单3.4 源代码# include <stdio.h># include <stdlib.h># include <string.h>typedef struct linkchar number100;char bookname100;char author100;char publish100;char time100;float price;char status100; struct link *next;link;li

4、nk *Cbook()int n=0;link *p,*q,*head;FILE *fp;fp=fopen("图书信息.txt","r+");if(fp=NULL)printf("没有找到文件,请检查");p=(link *)malloc(sizeof(link);if(p=NULL)printf("申请内存出错!n");fscanf(fp,"%s%s%s%s%s",p->number,p->bookname,p->author,p->publish,p->time

5、);fscanf(fp,"%f",&p->price);fscanf(fp,"%s",p->status);while(feof(fp)=0)n+;if(n=1)head=p;elseq=p;p=(link *)malloc(sizeof(link);if(p=NULL)printf("申请内存出错!n");fscanf(fp,"%s%s%s%s%s",p->number,p->bookname,p->author,p->publish,p->time);fscan

6、f(fp,"%f",&p->price);fscanf(fp,"%s",p->status);q->next=p;p->next=NULL;fclose(fp);printf("信息已录入!");return head;void mainmenu()printf("n*n");printf("n* 欢迎使用图书管理系统 *n");printf("n* 1.进入系统 0.退出系统 *n");printf("n*n");prin

7、tf("n 请选择");void menu1()printf("n*n");printf("n* 1.进入图书查询系统 *n");printf("n* 2.进入图书借还系统 *n");printf("n* 3.保存所有图书信息 *n");printf("n* 4.返回上级菜单 *n");printf("n*n");printf("n请选择");void cxmenu()printf("n*n"); printf(&q

8、uot;n* 1.显示所有图书信息 *n"); printf("n* 2.按编号查询图书 *n"); printf("n* 3.按书名查询图书 *n"); printf("n* 4.按作者查询图书 *n"); printf("n* 5.返回上级菜单 *n");printf("n*n"); printf("n请选择");void jhmenu()printf("n*n");printf("n* 1.借书 *n");printf(

9、"n* 2.还书 *n");printf("n* 3.返回上级菜单 *n");printf("n*n");printf("n请选择"); void print(link *head)link *p;p=head;printf("n");printf("n*n");printf("n编号tt书名tt作者tt出版社tt出版时间tt价格tt状态n"); while(p!=NULL) printf("n");printf("%st%s

10、t%st%st%s",p->number,p->bookname,p->author,p->publish,p->time);printf("tt%.2f",p->price);printf("tt%s",p->status);printf("n");p=p->next;void hold(link *head)link *p;FILE *fp;fp=fopen("图书信息.txt","w+");if(fp=NULL)printf(&qu

11、ot;文件操作出错!");exit(1);p=head;for(;p!=NULL;p=p->next) fprintf(fp,"%st%st%st%st%s",p->number,p->bookname,p->author,p->publish,p->time);fprintf(fp,"tt%.2f",p->price);fprintf(fp,"tt%s",p->status);fprintf(fp,"n");fclose(fp);printf("

12、信息已保存。");void holdcx(link *t)link *p=NULL;FILE *fp;fp=fopen("查询.txt","a+");p=t;fprintf(fp,"查询到的信息为:n");fprintf(fp,"n");fprintf(fp,"n*n");fprintf(fp,"n编号tt书名tt作者tt出版社tt出版时间tt价格tt状态n");fprintf(fp,"n");fprintf(fp,"%st%st%st

13、%st%s",p->number,p->bookname,p->author,p->publish,p->time);fprintf(fp,"tt%.2f",p->price);fprintf(fp,"tt%s",p->status);fprintf(fp,"n");fclose(fp);printf("信息已保存!");link *findnumber(link *head)char key100;link *h,*t1=NULL;printf("请输

14、入图书的编号:");getchar();gets(key);for(h=head;h!=NULL;h=h->next) if(strcmp(key,h->number)=0) t1=h; break; return t1; link *findboookname(link *head)char key100;link *h,*t2=NULL;printf("请输入图书的书名:");getchar();gets(key);for(h=head;h!=NULL;h=h->next) if(strcmp(key,h->bookname)=0) t

15、2=h; break; return t2;link *findauthor(link *head)char key100;link *h,*t3=NULL;printf("请输入作者姓名:");getchar();gets(key);for(h=head;h!=NULL;h=h->next) if(strcmp(key,h->author)=0) t3=h; break; return t3;link *sortnumber(link *head)link *p,*q,*temp; temp=(link *)malloc(sizeof(link); if(te

16、mp=NULL) printf("申请内存出错!"); exit(1); for(p=head;p!=NULL;p=p->next) for(q=p->next;q!=NULL;q=q->next)if(strcmp(p->number,q->number)>0) strcpy(temp->number,p->number); strcpy(temp->bookname,p->bookname); strcpy(temp->author,p->author); strcpy(temp->publi

17、sh,p->publish); strcpy(temp->time,p->time); temp->price=p->price; strcpy(temp->status,p->status); strcpy(p->number,q->number); strcpy(p->bookname,q->bookname); strcpy(p->author,q->author); strcpy(p->publish,q->publish); strcpy(p->time,q->time); p-&g

18、t;price=q->price; strcpy(p->status,temp->status); strcpy(q->number,temp->number); strcpy(q->bookname,temp->bookname); strcpy(q->author,temp->author); strcpy(q->publish,temp->publish); strcpy(q->time,temp->time); q->price=temp->price; strcpy(q->status,t

19、emp->status); return head; link *borrowbook(link *head)link *h,*p;char ch,ch1100="在库",ch2100="不在库"h=head;printf("n*n");printf("tt欢迎使用借书系统!n");p=findboookname(h);if(p=NULL)printf("借书失败,书库中没有这本书!");else if(strcmp(p->status,ch2)=0)printf("借书失

20、败,图书不在库!");else printf("确认借出?Y/N:");scanf("%c",&ch);getchar(); if(ch='Y'|ch='y') strcpy(p->status,ch2); printf("借书成功,请返回上级菜单保存信息!");if(ch='N'|ch='n')printf("你没有借任何书!"); return head; link *returnbook(link *head) link

21、*h,*p; char ch,ch1100="在库",ch2100="不在库" h=head;printf("n*n");printf("tt欢迎使用还书系统!n");p=findboookname(h);if(p=NULL)printf("还书失败,这不是本书库的书!"); else printf("确认还书?Y/N:"); scanf("%c",&ch); getchar(); if(ch='Y'|ch='y')

22、 strcpy(p->status,ch1); printf("还书成功,请返回上级菜单保存信息!"); if(ch='N'|ch='n') printf("你没有还书!"); return head; void main()int a,b,c,d;link *h,*t;L:system("cls"); mainmenu();while(1) scanf("%d",&a);switch(a)case 1: B: system("cls"); menu

23、1(); while(1) scanf("%d",&b); switch(b) case 1: system("cls"); cxmenu(); while(1) scanf("%d",&c); switch(c) case 1: print(h); break; case 2: t=findnumber(h); if(t=NULL) printf("没有要查询的图书!"); if(t!=NULL) printf("查询的图书为:"); printf("n")

24、; printf("n*n"); printf("n编号tt书名tt作者tt出版社tt出版时间tt价格tt状态n"); printf("n");printf("%st%st%st%st%s",t->number,t->bookname,t->author,t->publish,t->time); printf("tt%.2f",t->price); printf("tt%s",t->status);printf("n&quo

25、t;); break; case 3: t=findboookname(h); if(t=NULL) printf("没有要查询的图书!"); if(t!=NULL) printf("查询的图书为:"); printf("n");printf("n*n"); printf("n编号tt书名tt作者tt出版社tt出版时间tt价格tt状态n"); printf("n");printf("%st%st%st%st%s",t->number,t->bo

26、okname,t->author,t->publish,t->time); printf("tt%.2f",t->price); printf("tt%s",t->status); printf("n"); break; case 4: t=findauthor(h); if(t=NULL) printf("没有要查询的图书!"); if(t!=NULL) printf("查询的图书为:"); printf("n"); printf("

27、n*n"); printf("n编号tt书名tt作者tt出版社tt出版时间tt价格tt状态n"); printf("n");printf("%st%st%st%st%s",t->number,t->bookname,t->author,t->publish,t->time); printf("tt%.2f",t->price); printf("tt%s",t->status);printf("n"); break; case 5: goto

温馨提示

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

评论

0/150

提交评论