图书馆管理系统 数据结构大作业Word格式文档下载.docx

上传人:b****7 文档编号:21790558 上传时间:2023-02-01 格式:DOCX 页数:39 大小:136.96KB
下载 相关 举报
图书馆管理系统 数据结构大作业Word格式文档下载.docx_第1页
第1页 / 共39页
图书馆管理系统 数据结构大作业Word格式文档下载.docx_第2页
第2页 / 共39页
图书馆管理系统 数据结构大作业Word格式文档下载.docx_第3页
第3页 / 共39页
图书馆管理系统 数据结构大作业Word格式文档下载.docx_第4页
第4页 / 共39页
图书馆管理系统 数据结构大作业Word格式文档下载.docx_第5页
第5页 / 共39页
点击查看更多>>
下载资源
资源描述

图书馆管理系统 数据结构大作业Word格式文档下载.docx

《图书馆管理系统 数据结构大作业Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《图书馆管理系统 数据结构大作业Word格式文档下载.docx(39页珍藏版)》请在冰豆网上搜索。

图书馆管理系统 数据结构大作业Word格式文档下载.docx

通过书号、书名、作者三种查找方式查询借书,借书成功后,该书的可借书量减1,读者借书量减1。

流程图如下:

3.还书:

voidreturnbook(book*bhead,reader*temp);

输入书号,查询是否存在,然后还书,该书的可借书量加1,读者借书量加1。

详细程序模块

1、头文件定义

头文件library.h定义了3个结构体:

书籍结构体、读者结构体和索引表结构体,

书籍结构体的定义如下:

typedefstructREADER{

longnumber;

//借阅号

charname[15];

//读者姓名

charsex;

//读者性别

charpassword[16];

//读者的密码

intresidue;

//读者的剩余可借书籍数量

longborrowed[10];

//读者已经借阅的书籍编号

intlimit;

//读者权限

structREADER*next;

}reader;

读者结构体的定义如下:

typedefstructBOOK{

//书籍编号

charname[30];

//书名

charauthor[30];

//作者

charpress[30];

//出版社信息

longpresstime;

//出版日期

intexist;

//在库数量

inttotal;

//总数量

structBOOK*next;

}book;

索引表结构体的定义如下:

typedefstructKEY{

longkey;

book*adress;

structKEY*next;

}keynode;

头文件还包含一些系统头文件的声明:

#include"

stdio.h"

string.h"

conio.h"

windows.h"

还有一些函数的声明,用#ifndef、#endif来包含,以免重复包含。

2、插入模块

插入模块分为书籍入库、注册、登陆3大块,分3个函数,声明如下:

voidinsert(book*bhead);

//入库

voidreg(reader*head);

//注册

reader*login(reader*rhead,book*bhead);

//登陆

这3个函数分别实现新书入库、读者注册、登陆等功能,入库功能只有管理员才能调用,其余函数均可以调用。

3、读写模块

此模块主要实现向文件写入、读取数,主要是2个文件:

reader.txt、book.txt,分为4个函数:

读者读写函数,书籍读写函数。

定义如下:

book*Bload();

//书籍链表读取

reader*Rload();

//读者链表读入

voidBsave(book*Bhead);

//书籍链表写入

voidRsave(reader*Rhead,book*bhead);

//读者链表写入

读者和书籍链表的初始化就由读取函数完成,若文件为空则返回空指针,若不为空,则将文件里面的信息写入到链表中,每读出一个数据,分配一个空间,将该信息输入。

4、查找模块

查找模块分书籍查找模块、读者查找模块,书籍查找模块分线性链表查询、遍历查询、索引表查询,读者查询直接遍历读者链表,查找该读者,若存在,返回指针,不存在则返回NULL。

查找模块的定义如下:

book*S_name(book*head,charname[]);

//按书籍名查找函数

voidS_author(book*head);

//按作者查找

keynode*initindex(book*head);

//初始化建立索引表

book*S_number(longnum,book*bhead);

//按书号查找

reader*S_reader(reader*rhead,longnum);

//查找读者

5、显示模块

根据给出的节点指针,显示该节点所包含的信息,显示分为读者显示和书籍信息显示,读者信息显示包含书籍信息显示,以便显示读者所借书的信息。

这两个函数的声明如下:

voidshowR(reader*tr,book*bhead);

//显示读者信息函数

voidshowB(book*p);

//显示书籍信息函数

这个模块还有2个小函数,用于将存入的性别’F’、’M’转化成汉字,将存的权限“1”、“0”转化成“管理员”、“读者”输出,这两个函数的定义如下:

char*sc(charp)

{

if(p=='

F'

||p=='

f'

return"

女"

;

else

男"

}

char*lc(inti)

if(i==1)

管理员"

读者"

程序运行结果

1.登录界面:

2.入库界面:

3.借书界面:

4.还书界面:

5.个人信息查询界面:

体会

这次的大作业让我复习并实际运用本学期学的数据结构的有关知识,例如数据的存储、排序、调用、查找等,加深了对数据结构和C语言的理解,总的来说,收获颇丰。

代码

头文件library.h

#ifndefLIBRARY_INCLUDE

#defineLIBRARY_INCLUDE

#include<

stdio.h>

string.h>

conio.h>

stdlib.h>

windows.h>

time.h>

longnumber;

charname[30];

charauthor[30];

charpress[30];

longpresstime;

intexist;

inttotal;

structBOOK*next;

typedefstructKEY{

charname[15];

charsex;

charpassword[16];

intresidue;

longborrowed[10][2];

intlimit;

structREADER*next;

char*lc(inti);

char*sc(charp);

voidshowR(reader*tr,book*bhead);

voidshowB(book*p);

book*S_name(book*head,charname[]);

voidS_author(book*head);

keynode*initindex(book*head);

voiddelkey(keynode*keyhead);

book*S_number(longnum,book*bhead);

reader*S_reader(reader*rhead,longnum);

book*Bload();

reader*Rload();

voidBsave(book*Bhead);

voidRsave(reader*Rhead,book*bhead);

voidreg(reader*head);

reader*login(reader*rhead,book*bhead);

voidborrow(reader*temp,book*Bhead);

voidreturnbook(book*bhead,reader*temp);

voidstyle();

voidintpsd(char*psd);

voidmenu(structBOOK*Bhead,reader*Rhead);

voidmenu2(reader*temp,reader*rhead,book*bhead);

longbacktime();

#endif

借还书文件borrow_return.cpp

library.h"

voidborrow(reader*temp,book*Bhead)

style();

longnum;

inti;

chart,k,name[30];

book*Bbook;

getch();

system("

cls"

);

while

(1)

{

printf("

\n┏━━━━━━━━━━┓"

\n█━━━━━━━━━━━┫借书┣━━━━━━━━━━━█"

\n┗━━━━━━━━━━┛"

\n请输入您要查找借阅书籍的方式:

"

\n1、按书号查找\n"

\n2、按作者查找\n"

\n3、按书名查找\n"

\n4、返回主菜单\n"

t=getch();

switch(t)

{

case'

1'

:

printf("

\n请输入您要查找的书籍编号:

scanf("

%d"

&

num);

if((Bbook=S_number(num,Bhead))!

=NULL)

{

showB(Bbook);

printf("

\n请问你是否要借阅该书籍?

Y/N"

k=getch();

if(k=='

Y'

||k=='

y'

gotoborrow;

else

break;

}

else

break;

}

2'

S_author(Bhead);

break;

3'

\n请输如您要查找的书籍名:

%s"

name);

if((Bbook=S_name(Bhead,name))!

continue;

default:

return;

borrow:

if(Bbook!

=NULL&

&

temp->

residue>

0&

Bbook->

exist>

0)

temp->

residue--;

Bbook->

exist--;

for(i=0;

i<

10;

i++)

if(temp->

borrowed[i][0]==0)

{

temp->

borrowed[i][0]=Bbook->

number;

borrowed[i][1]=backtime();

}

\n借阅成功!

else

if(!

(temp->

0))

\n您只能借阅10本书籍!

if(!

(Bbook->

printf("

\n该书没有库存,请借阅其他书籍!

\n您要继续借阅书籍吗?

if(t=='

||t=='

continue;

break;

}

voidreturnbook(book*bhead,reader*temp)

inti,j=0;

chart;

book*p;

printf("

\n█━━━━━━━━━━━┫还书┣━━━━━━━━━━━█"

\n\n请输入您所还书的编号:

scanf("

for(i=0;

if(num==temp->

borrowed[i][0])

j=1;

p=S_number(num,bhead);

if(p!

j==1)

\n┌────┬──────┬───────┬────┬───────┐"

\n│书本编号│书籍名称│出版社名称│出版时间│作者│"

\n├────┼──────┼───────┼────┼───────┤"

\n│%8d│%12s│%14s│%8d│%14s│"

p->

number,p->

name,p->

press,p->

presstime,p->

author);

\n└────┴──────┴───────┴────┴───────┘\n"

\n确认归还该书籍?

p->

exist++;

residue++;

borrowed[i][0]==num)

borrowed[i][0]=0;

borrowed[i][1]=0;

elsereturn;

\n编号有误,请仔细检查!

新书入库insert.cpp

#include"

voidinsert(book*bhead)

longt;

book*temp1,*temp,*temp2;

temp1=bhead->

next;

\n█━━━━━━━━━━━┫入库┣━━━━━━━━━━━█"

\n请输入您给定书的编号(6位以内的正整数):

scanf("

t);

if(t<

=0||t>

999999)

\n您的编号不在处理范围(1~999999)之内!

fflush(stdin);

temp2=S_number(t,bhead);

if(temp2==NULL)

temp2->

total++;

\n编号为%d的书已存在,入库成功!

t);

return;

temp=(book*)malloc(sizeof(book));

temp->

number=t;

\n请输入书名:

temp->

name);

\n请输入本书作者:

\n请输入本书出版社:

press);

\n请输入本书出版时间:

presstime);

next=NULL;

total=1;

exist=1;

if(bhead->

next==NULL)

bhead->

next=temp;

while(temp1->

next!

temp1->

number<

number)

temp1=temp1->

temp->

next=temp1->

temp1->

\n█━━━━━━━━━━━┫入库成功┣━━━━━━━━━━━█"

voidreg(reader*head)

longi=1000;

intj;

chart1[16],t2[16];

reader*temp=head->

reader*p;

p=new(reader);

\n█━━━━━━━━━━━┫注册┣━━━━━━━━━━━█"

\n请输入姓名:

fflush(stdin);

\n请输入性别:

\nM:

男性:

\nF:

女性:

p->

sex=getchar();

if(p->

sex=='

||p->

M'

m'

\n阁下既非男,又非女,莫非来自泰国?

while

(1)

\n请输入您的密码:

intpsd(t1);

if(strlen(t1)<

=4)

\n您设置的密码过于简单,请重新设置:

\n请确认您的密码:

intpsd(t2);

if(strcmp(t1,t2)==0)

strcpy(p->

password,t1);

\n您两次输入的密码不一致!

p->

residue=10;

for(j=0;

j<

j++)

borrowed[j][0]=0;

borrowed[j][1]=0;

if(temp==NULL)

number=i;

head->

n

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 自然科学 > 物理

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1