图书管理系统源码及课程设计报告c语言版Word下载.docx

上传人:b****7 文档编号:22965684 上传时间:2023-02-06 格式:DOCX 页数:23 大小:152.22KB
下载 相关 举报
图书管理系统源码及课程设计报告c语言版Word下载.docx_第1页
第1页 / 共23页
图书管理系统源码及课程设计报告c语言版Word下载.docx_第2页
第2页 / 共23页
图书管理系统源码及课程设计报告c语言版Word下载.docx_第3页
第3页 / 共23页
图书管理系统源码及课程设计报告c语言版Word下载.docx_第4页
第4页 / 共23页
图书管理系统源码及课程设计报告c语言版Word下载.docx_第5页
第5页 / 共23页
点击查看更多>>
下载资源
资源描述

图书管理系统源码及课程设计报告c语言版Word下载.docx

《图书管理系统源码及课程设计报告c语言版Word下载.docx》由会员分享,可在线阅读,更多相关《图书管理系统源码及课程设计报告c语言版Word下载.docx(23页珍藏版)》请在冰豆网上搜索。

图书管理系统源码及课程设计报告c语言版Word下载.docx

//该元素在表中的位置,否则为0。

ST.elem[0].key=key;

//“哨兵”

for(i=ST.length;

ST.elem[i].key!

=key;

--i);

//从后往前找

returni;

//找不到时,i为0

}//Search_Seq、

动态查找表:

ADTDynamicSearchTable

D是具有相同特性的数据元素的集

数据元素同属一个集合

InitDSTable(&

DT);

构造一个空的动态查找表DT。

DestroyDSTable(&

态查找动表DT存在

销毁动态查找表DT

InsertDSTable(&

DT,e);

动态查找表DT存在,e

为待插入的数据元素;

若DT中不存在其关键字

等于e.key的数据元素,则插入e到DT。

图书结构体的定义:

typedefstruct{

charnumber[10];

//书号

charname[20];

//书名

charauthor[20];

//作者

intcountbook;

//库存

intshY;

//剩余量

}mbook;

typedefstruct{

intcount;

//书的本数

mbookbook[100];

//最大可有100本书

}mlibrary;

mlibrarylibrary;

三、详细设计

#include<

stdio.h>

#include<

string.h>

stdlib.h>

#include<

conio.h>

#defineMax2

typedefstructbook

{

charbook_num[10];

charbook_name[20];

charbook_writer[10];

intbook_xy;

intbook_kc;

structbook*next;

}BK;

typedefstructborrow

charborrow_book_num[10];

charlimit_date[8];

}BO;

typedefstructreader

charreader_num[10];

charreader_name[10];

intright;

BOborrow[Max];

structreader*next;

}RD;

BK*h_book;

RD*h_reader;

voidLogin();

intMenu();

voidInit();

voidInit_book();

voidMenu_select();

voidInsert_New_Book();

voidFind_Book();

voidadd_reader();

voidPrint_reader();

voidPrint_book();

voidBorrow_Book();

voidReturn_Book();

voidSave();

voidSave_Book();

voidSave_Reader();

voidLoad();

voidLoad_Reader();

voidLoad_Book();

intMenu()/*主菜单*/

{intdm;

printf("

\n\t\t图书管理系统主菜单\n"

);

=================================================\n"

<

\t0----退出系统>

>

\n"

\t1----采编入库>

\t2----登记读者>

\t3----借阅登记>

\t4---还书管理>

\n"

\t5---查询图书信息>

\t6----查询读者信息>

请选择相应的代码:

"

for(;

;

{scanf("

%d"

&

dm);

if(dm<

0||dm>

6)

printf("

\n错误!

请重新输入:

elsebreak;

}

returndm;

voidMenu_select()/*主菜单选择函数*/

switch(Menu())/*功能选择*/

{case0:

system("

cls"

Save();

\n\n\t文件保存成功!

\n\n\t欢迎下次使用本系统!

getch();

exit(0);

case1:

Insert_New_Book();

break;

case2:

add_reader();

case3:

Borrow_Book();

case4:

Return_Book();

case5:

Print_book();

case6:

Print_reader();

default:

exit(0);

voidInit()/*初始化*/

Init_book();

voidInit_book()/*初始化图书信息*/

BK*p0;

\n图书初始化开始,请输入图书信息..\n包括编号.书名.数量..\n"

p0=(BK*)malloc(sizeof(BK));

h_book=p0;

\n请输入图书信息:

图书编号:

/*输入图书编号(唯一)*/

scanf("

%s"

p0->

book_num);

图书名称:

/*输入图书名称*/

book_name);

图书作者:

/*输入图书作者*/

book_writer);

图书数量:

/*输入图书数量*/

p0->

book_kc);

p0->

book_xy=p0->

book_kc;

/*开始时图书现有量和库存量相等*/

next=NULL;

\n图书信息初始化完毕!

按任意键继续下一步操作..\n"

voidInsert_New_Book()/*新书入库*/

BK*p,*p0,*p1;

p=p1=h_book;

\n新书入库模块...\n"

\n请输入新书信息..\n包括书号.书名.数量..\n"

p0=(BK*)malloc(sizeof(BK));

while(strcmp(p0->

book_num,p1->

book_num)!

=0&

&

p1->

next!

=NULL)

p1=p1->

next;

if(strcmp(p0->

book_num)==0)/*此处分两种情况,若图书编号存在,则直接进库,只须输入书的数量*/

{

\n此编号图书已存在!

!

直接入库!

p1->

book_kc+=p0->

book_xy+=p0->

}

else/*若不存在,则需要输入其他的信息,然后在进行插入操作*/

while(p->

next)

{p=p->

if(h_book==NULL)h_book=p0;

/*此处分两种情况,链表中没有数据,head直接指向p0处*/

elsep->

next=p0;

/*此处分两种情况,链表中有数据,链表中最后元素的next指向p0处*/

\n新书入库完毕!

voidadd_reader()/*添加读者*/

{RD*p0;

inti;

\n读者初始化开始,请输入读者信息..\n包括书证号.姓名..\n"

p0=(RD*)malloc(sizeof(RD));

/*申请新结点存储空间*/

h_reader=p0;

\n请输入读者的信息:

读者书证号:

reader_num);

读者姓名:

scanf("

reader_name);

right=0;

for(i=0;

i<

Max;

i++)

strcpy(p0->

borrow[i].borrow_book_num,"

0"

/*所借图书直接置为0(即没有借书)*/

strcpy(p0->

borrow[i].limit_date,"

\n读者信息初始化完毕!

voidBorrow_Book()/*借书模块*/

RD*p1;

charbo_num[10],rea_num[10],lim_date[8];

inti;

p0=h_book;

p1=h_reader;

\n借书模块...\n"

\n请输入借书的读者书证号:

rea_num);

while(p1->

=NULL&

strcmp(rea_num,p1->

reader_num)!

=0)

if(p1->

next==NULL&

{

\n此读者编号不存在!

按任意键返回..\n"

gotoEND;

}

\n请输入你要借的书的编号:

bo_num);

while(strcmp(bo_num,p0->

=NULL)

p0=p0->

if(p0->

strcmp(bo_num,p0->

\n此图书编号不存在!

elseif(p0->

book_xy<

\n抱歉,此书已借完!

请等待新书的到来!

\n按任意键返回...."

elseif(p1->

right>

=Max)

\n不好意思,借书数目已满!

不能借书!

elseif(strcmp(p1->

borrow[0].borrow_book_num,"

)!

i++)

if(strcmp(p1->

borrow[i].borrow_book_num,bo_num)==0)

\n抱歉!

同一个读者不能同借两本相同的书!

elseif(strcmp(p1->

)==0)

\n请输入你要归还图书的日期:

lim_date);

strcpy(p1->

borrow[p1->

right++].borrow_book_num,bo_num);

right-1].limit_date,lim_date);

book_xy--;

\n读者编号%s借书完毕!

按任意键继续下步操作.."

p1->

else

right-1].limit_date,lim_date);

END:

getch();

}

voidReturn_Book()/*还书模块*/

BK*p;

RD*q;

inti,j,find=0;

charreturn_book_num[10],return_reader_num[10];

p=h_book;

q=h_reader;

\n还书模块...\n"

\n请输入要还书的读者编号:

return_reader_num);

while(q->

strcmp(return_reader_num,q->

q=q->

if(q->

=0)

find=2;

gotoend;

\n请输入读者还书的编号:

return_book_num);

while(p->

strcmp(return_book_num,p->

p=p->

if(p->

find=2;

此图书编号不存在!

if(strcmp(return_book_num,q->

borrow[i].borrow_book_num)==0)/*如果此读者借了此书*/

find=1;

for(j=i;

j<

Max-1;

j++)

strcpy(q->

borrow[j].borrow_book_num,q->

borrow[j+1].borrow_book_num);

borrow[j].limit_date,q->

borrow[j+1].limit_date);

borrow[Max-1].borrow_book_num,"

borrow[Max-1].limit_date,"

p->

book_xy++;

q->

right--;

\n编号%s的读者还书完毕!

if(find==0)

此读者未借此书!

end:

voidPrint_book()/*查询图书信息*/

\n图书信息如下:

\n\n"

图书编号\t图书名称\t图书作者\t现有\t\t库存\n"

while(p!

%s\t\t%s\t\t%s\t\t%d\t\t%d\n"

p->

book_num,p->

book_name,p->

book_writer,p->

book_xy,p->

\n图书信息打印完毕!

按任意键继续下一步操作.."

system("

voidPrint_reader()/*查询读者信息*/

RD*p;

p=h_reader;

\n读者信息如下:

读者书证号\t\t读者姓名\n"

\t%s\t\t%s"

reader_num,p->

图书编号"

i+1);

\t还书日期"

\t%s"

borrow[i].borrow_book_num);

\t\t%s"

borrow[i].limit_date);

\n读者信息打印完毕!

voidSave()/*保存信息*/

Save_Reader();

Save_Book();

voidSave_Reader()/*保存读者信息*/

FILE*fp_reader;

RD*p,*p0;

if((fp_reader=fopen("

Reader.txt"

"

wb"

))==NULL)/*创建文件,进行保存*/

\n文件保存失败!

\n请重新启动本系统...\n"

if(fwrite(p,sizeof(RD),1,fp_reader)!

=1)/*将链表中的信息写入文件中*/

\n写入文件失败!

\n请重新启动本系统!

p0=p;

free(p0);

/*释放所有结点*/

h_reader=NULL;

fclose(fp_reader);

/*关闭文件*/

voidSave_Book()/*保存图书信息*/

FILE*fp_book;

/*创建文件型指针*/

BK*p,*p0;

if((fp_book=fopen("

Book.txt"

if(fwrite(p,sizeof(BK),1,fp_book)!

h_book=NULL;

fclose(fp_book);

voidLoad()/*加载信息*/

Load_Reader();

Load_Book();

voidLoad_Reader()/*加载读者信息*/

RD*p1,*p2,*p3;

FILE*fp;

fp=fopen("

book.txt"

rb"

/*打开文件*/

p1=(RD*)malloc(sizeof(R

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

当前位置:首页 > IT计算机 > 电脑基础知识

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

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