收藏 分销(赏)

C语言图书管理系统课程设计论文.doc

上传人:二*** 文档编号:4496064 上传时间:2024-09-25 格式:DOC 页数:19 大小:156KB 下载积分:5 金币
下载 相关 举报
C语言图书管理系统课程设计论文.doc_第1页
第1页 / 共19页
本文档共19页,全文阅读请下载到手机保存,查看更方便
资源描述
第三章 图书管理系统的设计与实现 3.1系统的需求分析 图书登记管理系统作为一个应用软件将为学校的老师和学生提供一个对学校图书馆深入了解并借阅、还书的平台。根据系统界面的提示信息对图书馆信息进行查询、初始化等操作 系统功能需求分析描述如下: (1)系统主菜单:进入系统和退出系统 (2)功能菜单:显示可以进行的操作 (3)查询主菜单:根据图书编号、书名、作者进行查询,并可显示所有图书信息 (4)借还书主菜单:可以进行借书和还书等操作 3.2系统的设计 3.2.1 系统的总统设计 下面从系统的整体流程的功能模块、系统界面与数据结构进行总体设计。 (1)总体思想 本系统主要设计思想是实现图书馆的功能机管理系统信息的查询、借书、还书等主要功能。系统的设计方法是结构化实际方法,系统用C语言进行开发用户可以清晰的了解图书馆的情况。 (2)系统模块结构图 根据需求分析结果,图书管理系统可以分为三大模块:查询图书模块、借书功能模块、还书功能模块。 系统模块结构如图: 图书管理系统 还书功能系统 借书功能系统 图 书 管理主菜单 图书查询系统 3.2.2 系统的概要设计 ㈠系统主菜单。 显示系统的主菜单,里面有相应的功能代码,根据选择各功能代码进入不同的界面。功能主要包括:退出系统、查询图书、借书、还书。 ㈡查询图书信息 进入此菜单功能模块,输入您要查询的图书的编号、名字、作者等。 图书查询模块流程如图: 开始 提示输入图书编号、书名、作者 输入正确 查询 否 是 重新输入 是 退出系统 否 3.3 测试结果 系统主界面 功能菜单 查询系统菜单 借还系统菜单 3.4 源代码 # include <stdio.h> # include <stdlib.h> # include <string.h> typedef struct link { char number[100]; char bookname[100]; char author[100]; char publish[100]; char time[100]; float price; char status[100]; struct link *next; }link; link *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); fscanf(fp,"%f",&p->price); fscanf(fp,"%s",p->status); while(feof(fp)==0) { n++; if(n==1) { head=p; } else { q=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); fscanf(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"); printf("\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("\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("\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编号\t\t书名\t\t作者\t\t\t\t出版时间\t\t价格\t\t状态\n"); while(p!=NULL) { printf("\n"); printf("%s\t%s\t%s\t%s\t%s",p->number,p->bookname,p->author,p->publish,p->time); printf("\t\t%.2f",p->price); printf("\t\t%s",p->status); printf("\n"); p=p->next; } } void hold(link *head) { link *p; FILE *fp; fp=fopen("图书信息.txt","w+"); if(fp==NULL) { printf("文件操作出错!!!"); exit(1); } p=head; for(;p!=NULL;p=p->next) { fprintf(fp,"%s\t%s\t%s\t%s\t%s",p->number,p->bookname,p->author,p->publish,p->time); fprintf(fp,"\t\t%.2f",p->price); fprintf(fp,"\t\t%s",p->status); fprintf(fp,"\n"); } fclose(fp); printf("信息已保存。"); } 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编号\t\t书名\t\t作者\t\t\t\t出版时间\t\t价格\t\t状态\n"); fprintf(fp,"\n"); fprintf(fp,"%s\t%s\t%s\t%s\t%s",p->number,p->bookname,p->author,p->publish,p->time); fprintf(fp,"\t\t%.2f",p->price); fprintf(fp,"\t\t%s",p->status); fprintf(fp,"\n"); fclose(fp); printf("信息已保存!!!"); } link *findnumber(link *head) { char key[100]; link *h,*t1=NULL; printf("请输入图书的编号:"); 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 key[100]; link *h,*t2=NULL; printf("请输入图书的书名:"); getchar(); gets(key); for(h=head;h!=NULL;h=h->next) { if(strcmp(key,h->bookname)==0) { t2=h; break; } } return t2; } link *findauthor(link *head) { char key[100]; 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(temp==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->publish,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->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,temp->status); } } } return head; } link *borrowbook(link *head) { link *h,*p; char ch,ch1[100]="在库",ch2[100]="不在库"; h=head; printf("\n**************************************************\n"); printf("\t\t欢迎使用借书系统!!!\n"); p=findboookname(h); if(p==NULL) printf("借书失败,书库中没有这本书!!!"); else if(strcmp(p->status,ch2)==0) printf("借书失败,图书不在库!!!"); 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 *h,*p; char ch,ch1[100]="在库",ch2[100]="不在库"; h=head; printf("\n**************************************************\n"); printf("\t\t欢迎使用还书系统!!!\n"); p=findboookname(h); if(p==NULL) printf("还书失败,这不是本书库的书!!"); else { printf("确认还书?Y/N:"); scanf("%c",&ch); getchar(); if(ch=='Y'||ch=='y') { 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"); menu1(); 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"); printf("\n**************************************************\n"); printf("\n编号\t\t书名\t\t作者\t\t\t\t出版时间\t\t价格\t\t状态\n"); printf("\n"); printf("%s\t%s\t%s\t%s\t%s",t->number,t->bookname,t->author,t->publish,t->time); printf("\t\t%.2f",t->price); printf("\t\t%s",t->status); printf("\n"); } }break; case 3: { t=findboookname(h); if(t==NULL) printf("没有要查询的图书!!!"); if(t!=NULL) { printf("查询的图书为:"); printf("\n"); printf("\n**************************************************\n"); printf("\n编号\t\t书名\t\t作者\t\t\t\t出版时间\t\t价格\t\t状态\n"); printf("\n"); printf("%s\t%s\t%s\t%s\t%s",t->number,t->bookname,t->author,t->publish,t->time); printf("\t\t%.2f",t->price); printf("\t\t%s",t->status); printf("\n"); } }break; case 4: { t=findauthor(h); if(t==NULL) printf("没有要查询的图书!!!"); if(t!=NULL) { printf("查询的图书为:"); printf("\n"); printf("\n**************************************************\n"); printf("\n编号\t\t书名\t\t作者\t\t\t\t出版时间\t\t价格\t\t状态\n"); printf("\n"); printf("%s\t%s\t%s\t%s\t%s",t->number,t->bookname,t->author,t->publish,t->time); printf("\t\t%.2f",t->price); printf("\t\t%s",t->status); printf("\n"); } } break; case 5: { goto B; }break; } } }break; case 2: { system("cls"); jhmenu(); while(1) { scanf("%d",&d); switch(d) { case 1: { borrowbook(h); }break; case 2: { returnbook(h); }break; case 3: { goto B; }break; } } }break; case 3: { hold(h); }break; case 4: { goto L; }break; } } }break; case 0: { printf("\t\t\t感使用,再见!!!"); exit(0); } } } } 第四章 心得体会 经过一个多星期的编译原理课程设计,在我的努力下,顺利完成该课程设计。 通过该课程设计,掌握了编译程序工作的基本过程与其各阶段的基本任务,熟悉了编译程序总流程框图,了解了编译程序的生成过程与其相关的技术,对课本上的知识也有了更深的理解。老师常说,课本上的知识是机械的,表面的,要学会去运用,要举一反三。现在终于深刻的了解了这句话。经过这次的课程设计,发现书本上很深奥的知识变的更为简单,同样,对实验原理也了有更深的理解。知道和理解了该理论在计算机中是怎样执行的, 对该理论在实践中的应用有深刻的理解 。通过该课程设计,把死板的课本知识变得生动有趣,激发了学习的积极性。能够把课堂上学的知识通过自己设计的程序表示出来,加深了对理论知识的理解。 课程设计中程序比较复杂,在调试时应该仔细,在程序调试时,注意指针,将不必要的命令去除。除了课堂外,课程设计是最能学到东西的,最考验人的。在做课程设计的这段时间,时刻都感到自己学的知识有多么的贫瘠。经过这次课程设计,让我对C++这门语言有了更深的认识,操作能力有了提高要想是写出的代码能运行,需要耐心细心,毅力以与充沛的体力。只有经过多次编辑,多次编译,再多次运行,才能编写出更好的程序,有时候需要多次的更正才能达到所要的运行结果。 参考文献 谭洁强 《C程序设计》 清华大学 基温 《C程序设计案例教程》 清华大学 王宏 《C#程序设计案例教程》 清华大学 18 / 19
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 学术论文 > 其他

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2025 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服