


下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、苏州市职业大学课程设计任务书课程名称:计算机语言 C起讫时间:2007-12-31 至 2008-1-4院系:计算机工程系班级:07软件测试指导教师:李金祥顾小晶系主任:宣仲良苏州市职业大学课程设计说明书名称:计算机语言C课程设计图书登记管理程序2007年12月31日至 2008年1月4日共 1周院 系班 级 07软件测试姓 名马宝珠系主任教研室主任叶良指导教师李金祥 顾小晶1. 需求分析图书登记管理系统作为一个应用软件将为学校的老师和学生提供一个对学校图书馆深入了解并借阅、还书的平台。拥护根据系统界面的提示信息对图书馆信息进行查询、初始化等操作系统功能需求分析描述如下 :(1)查询图书: 根
2、据图书编号进行查询, 读者可以浏览或查询相关图书(2)系统主菜单:若未找到相应的书籍返回到上一级目录。(3)图书登记:读者输入要查询的编号、出版社、作者姓名等信息,系 统将进行处理。(4)初始化:输入书号、书名、书籍的数量以空格隔开,建立新文件写 入数据否则初始化失败。( 5 )新书入库:可读入新书名称、编号、数量以空格隔开看是否有此类书籍。(6)借书菜单:可输入读者编号和所借书编号或调用借书函数执行借书功能。(7)还书菜单:可输入读者编号和所还书的编号执行还书功能,还书后 修改图书库存量。(8)保存连接数据:方便读者了解图书登记的相关信息,为图书管理人员和读者带来便利。2. 总体设计下面从系
3、统的整体流程的功能模块系统界面与数据结构进行总体设计。(1) 总体思想本系统主要设计思想是实现图书馆的功能机管理系统信息的查询、 初始化、添加新书、借书、还书等主要功能。图书登记管理情况以文件的 形式储存,系统的人机接口系用简单的字符界面进行交互,系统的设计方 法是结构化实际方法,系统用 C语言进行幵发用户可以清晰的了解图书馆 内的情况。(2 )系统模块结构图根据需求分析结果,图书登记管理系统可以分为三大模块:查询图 书模块、图书登记管理模块、系统控制平台。系统模块结构如图:图书管理系魏图书管理主莱单TH书功能乘统一1B全部信息模珠光川永块、:壬養单糅按,系统初船化模坟:唐书系躱摸块:囹书查诲
4、模块:怀书系球模按、扁出全部信兒樽块3、概要设计系统主菜单。显示系统的主菜单,里面有相应的功能代码,根据选择各功能代码进 入不同的界面。功能主要包括:退出系统、查询图书、借书、还书、新书 入库。查询图书信息进入此菜单功能模块,输入您要查询的图书的编号、名称、作者、出 版日期等。图书查询模块流程如图图书登记管理模块根据功能选择进行操作,主要包括建立图书入库文件的保存与修改, 借书、还书文件的建立与修改。对系统进行初始化。4、数据结构设计图书信息和读者信息的数据结构系统云运用结构体来存放图书的 编号、作者、出版、借书、还书、新书入库,读者的编号、姓名、借书名 称等信息。下面是结构体的简单描述:ty
5、pedef struct bkchar book_ nu m11;char book_ name41; int book_kc;int book_xc;struct bk * next;book;typedef struct rdchar reader_num11;char reader_name11;char reader_book_num11;struct rd * next ;reader;5 、系统流程描述系统进行初始化后, 根据提示输入图书、 读者的相关信息后系统进入了 主菜单,根据选择相应的功能代码进入不同的功能菜单。主要包括退出系 统、新书入库、图书查询、借书、还书、输出所有信息
6、功能。选择代码按 回车键即可进入,进入功能模块后出现了不同选象,下面以进入借宿书模 块为例:进入借书模块后系统将提醒选择 1 可返回主菜单,选择 2 可正式进入 借书系统。选择 2 后,系统提示“请输入所借书的相关信息,读者的相关 信息。图 书 > 询*甭统初始化屮1r圉书管理主菜 单选择o代码一新书库存还书+谕 出 所 有 信 息J #僧书泵统输出栢关 馆息6、界面设计一、系统主菜单void M_Form() char ch;prin tf("nThe main wi ndow of books man age ");prin tf("n 0:Exit&q
7、uot;);prin tf("n 1:New book in store");printf("n 2:Book check");printf("n 3:Borrow book check in");printf("n 4:Return book check in");printf("n 5:Out put all information");doprintf("nn Please chose the code: ");scanf("%c",&ch)
8、;fflush(stdin);while(ch!='0'&&ch!='1'&&ch!='2'&&ch!='3'&&ch!='4'&&ch!='5')Jswitch(ch) case '0':exit(0);case '1':Form_Insert_New_Book();break;case '2':Form_Find_Book();break;case '3'
9、;:Form_Borrow_Book();break;case '4':Form_Return_Book();break;case'5':load_data();print_book(h_book);print_reader(h_reader);M_Form( );default:printf("errorn");exit(0);Thft main yiniioui nF hnnkf: manage9:Exit1 =Neu Jbuijk Ins Xu2"Book check3 :Boffw be ok check in4 = Rt:
10、 t-urn boo K 心hGck in& :Out wt si! infomat ianPlcrtie cliue Llie c-udei_L主糜单界面二、系统初始化模块void ini t_book() book ba3;FILE *fp;int i;printf("n System will initialize , Book initialize module :n");printf("n Enter 3books ' num , name , quantity(Space out withblank): n ");for(i=
11、0;i<3;i+)sea nf("%s%s%d",bai.book_ nu m,bai.book_ name,&bai.book_kc);for(i=0;i<3;i+) bai.book_xc二bai.book_kc;if(fp=fope n("book.dat","wb")=NULL) printf("Book 't be founded, Initialize fail ! Please restar system !n"); return; for(i=0;i<3;i+) i
12、f(fwrite(&bai,sizeof(struct bk),1,fp)!=1) printf("Write date wrong! n"); exit(0); fclose(fp);三、新书入库模块void In sert_New_Book(char book_ nu m,char book_ name,i ntnu mber) struct bk *book_fp;struct bk *p,*q,*t;q=P=h_book;while(p!二NULL&&strcmp(p->book_ nu m,book_ nu m)!=0) q=p;p=
13、p->n ext; if(strcmp(p->book_ nu m,book_ nu m)=0) printf("nttThis num already exist, Please reorder!'n");retur n;t=(struct bk *)malloc(sizeof(struct bk);strcpy(t->book_num,book_num); strcpy(t->book_name,book_name);t->book_kc=t->book_xc=number;q->next=t;t->next=NU
14、LL;if(book_fp=fopen("book.dat","ab")=NULL) printf("Book 't be founded,Initialize fail ! Please restar system !n"); return; fwrite(t,sizeof(struct bk),1,book_fp);fclose(book_fp);void print_book(struct bk *h) struct bk *p;p=h;printf("ntBook numtBook nametStore qu
15、antitytNowquantityn");while(p!=NULL) printf(" %10st %10s %10dt%10dn",p->book_num,p->book_na me,p->book_kc,p->book_xc);p=p->next;四、借书模块void Borrow_Book(char reader_ nu m,char book_ nu m) struct bk *book_p;struct rd *reader_p;book_p=h_book;while(book_p!二NULL&&strc
16、mp(book_p->book_ nu m,book_ nu m)!二0)book_p=book_p->n ext;if(book_p=NULL) printf("n'tThis num of book no exist! n”);Form_Borrow_Book();reader_p=h_reader;while(reader_p!=NULL&&( strcmp(reader_p->reader_ nu m,reader_ num)!=0)reader_p=reader_p->n ext;if(reader_p=NULL) print
17、f("ntThis num of reader no exist! n");Form_Borrow_Book();else if(strcmp(reader_p->reader_book_num,"0")!=0)! n"); printf("ntalready reach the top, Can't borrow againForm_Borrow_Book();else book_p->book_xc=book_p->book_xc-1; strcpy(reader_p->reader_book_nu
18、m,book_p->book_num); save();load_data();Form_Borrow_Book();五、还书功能模块void Retur n_Book(char reader_ nu m,char book_ nu m) struct bk *book_p;struct rd *reader_p;book_p=h_book;while(book_p!二NULL&&strcmp(book_p->book_ nu m,book_ nu m)!二0)book_p=book_p->n ext;if(book_p=NULL) printf("
19、n'tThis num of book no exist! n”);Form_Retur n_Book();reader_p=h_reader;while(reader_p!=NULL&&( strcmp(reader_p->reader_ nu m,reader_ n um)!=0) reader_p=reader_p->next;if(reader_p=NULL) printf("nttThis num of reader no exist! n");Form_Return_Book();else if(strcmp(reader_p
20、->reader_book_num,book_num)!=0) printf("ntReader didn't borrow this bookn");Form_Return_Book();else book_p->book_xc=book_p->book_xc+1;strcpy(reader_p->reader_book_num,"0");save();load_data();Form_Return_Book();六、输出所有信息模块void Formnsert_New_Book() char ch;struct bk
21、t;printf("n New book instor module,Please chose the code : n");prin tf(" 0:Retur n main menun");prin tf(" 1:New book in store");doprintf("nn Please chose the code:");sca nf("%c", &ch);fflush(stdi n);while(ch!='0'&&ch!='1'&
22、amp;&ch!='2'&&ch!=3&&ch!='4'&&ch!='5')Jswitch(ch) case 'O':M_Form();break;case '1': printf(" nEnter book's num name quantity( Space out withblank ):");sea nf("%s%s%d",t.book_ nu m,t.book_ name,& t.book_kc
23、);fflush(stdi n);In sert_New_Book(t.book_ nu m,t.book_ name,t.book_kc);Form _ln sert_New_Book();default:pri ntf("errorn");exit(O);-|n| x|he nain wmdoy -of books rvanagre 8:Exit1 -New lioulk insttJi'c:2*Bool eheck3:Borrov Bock check in4-Return ibodk clieck in5 : Out put alL IiriFopniaLt
24、 xonPlease chose the codeRnnk num010203fi4B00K4Fnnk nanR ho okl book2 book3501020罷2030砧Nnw anAntituFcaclez'1 s noneTlic nun of h jls Ijo iri'u01>a02zhao03shuSi出蔚有信息界面程序清单:#in elude <stdio.h>#in elude vgraphics.h>#in clude <math.h> #include <string.h>typedef struct bkc
25、har book_num11;char book_name41;int book_kc;int book_xc;struct bk * next;book;typedef struct rdchar reader_num11;char reader_name11;char reader_book_num11;struct rd * next ;reader;struct bk * h_book,* h_reader;void Form_Insert_New_Book();void Form_Find_Book();void Form_Borrow_Book();void Form_Return
26、_Book();void Find_Book(char *);void Borrow_Book(char *,char *);void Return_Book(char *,char *);void print_book(struct bk *);void print_reader(struct rd *);void load_data();void init_reader();void init_book();void save();void M_Form() char ch;printf("nThe main window of books manage ");prin
27、tf("n 0:Exit");printf("n 1:New book instore");printf("n 2:Book check");printf("n 3:Borrow book check in");printf("n 4:Return book check in");printf("n 5:Out put all information");doprintf("nn Please chose the code: ");scanf("
28、%c",&ch);fflush(stdin); while(ch!='0'&&ch!='1'&&ch!='2'&&ch!='3'&&ch!='4'&&ch!='5')switch(ch) case '0':exit(0);case '1':Form_Insert_New_Book();break;case '2':Form_Find_Book();brea
29、k;case '3':Form_Borrow_Book();break;case '4':Form_Return_Book();break;case'5':load_data();print_book(h_book);print_reader(h_reader);M_Form();default:printf("errorn");exit(0);void Form_Find_Book() char ch;char book_num11;printf("n Book check module, Please chose
30、 the code :n");printf(" 0:Return to main menun");printf(" 1:Book check");doprintf("nn Please chose the code: ");scanf("%c",&ch);fflush(stdin);while(ch!='0'&&ch!='1');switch(ch) case '0':M_Form();break;case '1':
31、printf(" nEnter need book' s num:");scanf("%s",book_num);fflush(stdin);Find_Book(book_num);Form_Find_Book();default:printf("errorn");exit(0);void Find_Book(char book_num) struct bk *p;p=h_book;while(p!=NULL&&strcmp(p->book_num,book_num)!=0) p=p->next;!
32、n");if(p=NULL) printf("ntThe num of book no exist else printf("ntBook numtBook nametStoreroom quantitytNow quantity n"); printf(" %10st %10st %dt %dtn",p->book_num,p->book_nam e,p->book_kc,p->book_xc);getch();void init_book() book ba3;FILE *fp;int i;printf(&
33、quot;n System will initialize,Book initialize module :n");printf("n Enter 3books' num , name ,quantity ( Space out withblank ):n ");for(i=0;i<3;i+) scanf("%s%s%d",bai.book_num,bai.book_name,&bai.book_kc);for(i=0;i<3;i+) bai.book_xc=bai.book_kc; if(fp=fopen(&quo
34、t;book.dat","wb")=NULL) printf("Book 't be founded,Initialize fail ! Please restar system !n"); return; for(i=0;i<3;i+) if(fwrite(&bai,sizeof(struct bk),1,fp)!=1) printf("Write date wrong! n"); exit(0); fclose(fp);void init() int drive=DETECT,mode=0; ini
35、tgraph(&drive,&mode,"");init_book(); init_reader();void Insert_New_Book(char book_num,char book_name,int number) struct bk *book_fp;struct bk *p,*q,*t; q=p=h_book;while(p!=NULL&&strcmp(p->book_num,book_num)!=0) q=p;p=p->next; if(strcmp(p->book_num,book_num)=0) prin
36、tf("nttThis num already exist, Please reorder!n");return;t=(struct bk *)malloc(sizeof(struct bk); strcpy(t->book_num,book_num); strcpy(t->book_name,book_name);t->book_kc=t->book_xc=number; q->next=t;t->next=NULL;if(book_fp=fopen("book.dat","ab")=NULL)
37、printf("Book 't be founded,Initialize fail ! Please restar system !n"); return; fwrite(t,sizeof(struct bk),1,book_fp); fclose(book_fp);void print_book(struct bk *h) struct bk *p;p=h;printf("ntBook numtBook nametStore quantitytNow quantityn");while(p!=NULL) printf(" %10st
38、 %10s %10dt%10dn",p->book_num,p->book_na me,p->book_kc,p->book_xc);p=p->next;void print_reader(struct rd *h) struct rd *p;p=h; printf("ntReader's numtRead's nametThe num of his borrown");while(p!=NULL) printf(" %10st %10s %10sn",p->reader_num,p->
39、reader_name,p ->reader_book_num);p=p->next;getch();void Form_Borrow_Book() char ch;char book_num11,reader_num11;printf("n Book borrow module, Please chose the code : n");printf(" 0:Return main menun");printf(" 1:Book borrown");doprintf("nn Please chose the co
40、de: ");scanf("%c",&ch);fflush(stdin); while(ch!='0'&&ch!='1');switch(ch) case '0':M_Form();break;case '1': printf(" nEnter read's num and borrow book's num:( Space outwith blank ) ");scanf("%s%s",reader_num,book_n
41、um);fflush(stdin);Borrow_Book(reader_num,book_num);Form_Borrow_Book(); default:printf("errorn");exit(0);void Borrow_Book(char reader_num,char book_num) struct bk *book_p;struct rd *reader_p; book_p=h_book;while(book_p!=NULL&&strcmp(book_p->book_num,book_num)!=0) book_p=book_p-&g
42、t;next;if(book_p=NULL) printf("ntThis num of book no exist! n");Form_Borrow_Book();while(reader_p!=NULL&&(strcmp(reader_p->reader_num,reader_num)!=0)reader_p=reader_p->next; if(reader_p=NULL) printf("ntThis num of reader no exist! n");Form_Borrow_Book();else if(strc
43、mp(reader_p->reader_book_num,"0")!=0) printf("ntalready reach the top,Can't borrow again ! n");Form_Borrow_Book();else book_p->book_xc=book_p->book_xc-1; strcpy(reader_p->reader_book_num,book_p->book_num); save();load_data();Form_Borrow_Book();void Form_Return_
44、Book() char ch;:n");Space outprintf("n Return book module,Please chose the codeprintf(" 0:Return main menun");printf(" 1:Return bookn");doprintf("nn Please chose the code: ");scanf("%c",&ch);fflush(stdin);while(ch!='0'&&ch!='1
45、');switch(ch) case '0':M_Form();break;case '1': printf(" nEnter reader's num and return book's num: with blank ) ");scanf("%s%s",reader_num,book_num);fflush(stdin);Return_Book(reader_num,book_num); Form_Return_Book();default:printf("errorn");
46、exit(0); struct bk *book_p;struct rd *reader_p;book_p=h_book;while(book_p!=NULL&&strcmp(book_p->book_num,book_num)!= 0)book_p=book_p->next; if(book_p=NULL) printf("ntThis num of book no exist! n");Form_Return_Book();reader_p=h_reader;while(reader_p!=NULL&&(strcmp(read
47、er_p->reader_num,reader_n um)!=0)reader_p=reader_p->next; if(reader_p=NULL) printf("nttThis num of reader no exist! n");Form_Return_Book();else if(strcmp(reader_p->reader_book_num,book_num)!=0) printf("ntReader didn't borrow this bookn"); Form_Return_Book(); else boo
48、k_p->book_xc=book_p->book_xc+1;strcpy(reader_p->reader_book_num,"0");save();load_data();Form_Return_Book();void init_reader() FILE *fp;reader ra3;int i;printf("n System will initialize reader:n");printf("n Enter 3 readers' num and name( Space out with blank ):n
49、");for(i=0;i<3;i+)scanf("%s%s",rai.reader_num,rai.reader_name);for(i=0;i<3;i+)strcpy(rai.reader_book_num,"0");if(fp=fopen("reader.dat","wb")=NULL) printf("Reader's 't be founded,initialize fail !Please restar system !n"); return; f
50、or(i=0;i<3;i+) if(fwrite(&rai,sizeof(struct rd),1,fp)!=1) printf("Write date wrong! n"); exit(0); void Form_Insert_New_Book() char ch;struct bk t;printf("n New book instor module,Please chose the code : n");printf(" 0:Return main menun");printf(" 1:New book
51、instore");doprintf("nn Please chose the code: ");scanf("%c",&ch);fflush(stdin); while(ch!='0'&&ch!='1'&&ch!='2'&&ch!='3'&&ch!='4'&&ch!='5') switch(ch) case '0':M_Form();break;
52、case '1': printf(" nEnter book's num name quantity( Space out withblank ): ");fflush(stdin);Insert_New_Book(t.book_num,t.book_name,t.book_kc); Form_Insert_New_Book();default:printf("errorn");exit(0);void load_data() struct bk *book_p1,*book_p2,*book_p3; struct rd *rea
53、der_p1,*reader_p2,*reader_p3; FILE *fp_book,*fp_reader;fp_book=fopen("book.dat","rb"); book_p1=(struct bk *)malloc(sizeof(struct bk); fread(book_p1,sizeof(struct bk),1,fp_book); h_book=book_p3=book_p2=book_p1;while(! feof(fp_book) book_p1=(struct bk *)malloc(sizeof(struct bk); fread(book_p1,sizeof(struct bk),1,fp_book); book_p2->next=book_p1;book_p3=book_p2;book_p2=book_p1; book_p3->next=NULL; free(boo
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年合肥建投资本管理有限公司社会招聘10人笔试参考题库附带答案详解
- 人教版高中地理选择性必修1第四章第二节洋流课件
- 滑坡地质灾害治理工程项目初步设计
- 刹车操作教学设计
- 2024年泉州市采购集团有限责任公司招聘劳务派遣人员1人笔试参考题库附带答案详解
- 外科手术护理相关知识
- 电子支付安全培训
- 2025至2030年中国锡黄铜棒数据监测研究报告
- 项目程序管理协议书(2篇)
- 2025至2031年中国数字式马达保护继电器行业投资前景及策略咨询研究报告
- 软硬结合板的设计制作与品质要求课件
- 中学葫芦丝校本教材
- SCADA系统基本功能检测记录
- 民营医院组织架构图示
- 慢性心功能不全护理查房
- 初中 初二 物理 凸透镜成像规律实验(习题课) 教学设计
- 消防维保方案 (详细完整版)
- 小学综合实践六年级上册第2单元《主题活动二:设计一周营养食谱》教案
- 学校教育信息化管理规章制度汇编
- 机械设备供货安装及售后服务方案(通用)
- 社区矫正人员工作手册
评论
0/150
提交评论