图书管理系统程序代码.docx
《图书管理系统程序代码.docx》由会员分享,可在线阅读,更多相关《图书管理系统程序代码.docx(53页珍藏版)》请在冰豆网上搜索。
图书管理系统程序代码
#include
#include
#include
#defineSIZE(structbooklist*)malloc(sizeof(structbooklist))
//建立已借阅图书信息结构体
structborrow
{
charborbook_num[10];
charborbook_name[22];
charreturn_time[15];
charstu_num[15];
charstu_name[15];
structborrow*next;
};
//建立预借图书信息结构体
structprebor_stu
{
charprebook_num[10];
charprestu_num[15];
structprebor_stu*next;
};
//建立图书结构体
structbooklist{
charnum[10];
charname[22];
charzuozhe[15];
charleibie[10];
charpub_time[10];
charprice[10];
charcondition[10];
structbooklist*next;
};
structbooklist*create(void);/*创建图书信息链表*/
structborrow*borrow_creat(structbooklist*head);//创建已借阅图书信息链表
intpre_creat(structbooklist*head);//学生登录系统预借图书并将信息存入文件prebor_stulist.txt
structprebor_stu*prebor_creat(void);//创建预借阅图书信息链表
voidprintf1_(structbooklist*);//输出单个基本图书的数据
voidstore(structbooklist*head);/*保存链表中的图书信息到文件booklist.txt*/
voidprintfb1_(structborrow*);//输出单个借出图书的部分数据
voidprintfb_(structborrow*p);//输出单个借出图书的数据
voidprintfp1_(structprebor_stu*);//输出单个被预借出图书的部分数据
voidprintfp_(structprebor_stu*);//输出单个被预借出图书的数据
voidprintf_(structbooklist*,structborrow*,structprebor_stu*);/*2---输出链表中的图书信息*/
structbooklist*load(void);//5---从文件读入图书信息
structbooklist*num_paixu(structbooklist*);//4---按编号排序
structbooklist*price_paixu(structbooklist*);//3---按价格顺序排序
intkcnum(structbooklist*head);//6---统计库存数
voidchaxun1_(structbooklist*,structborrow*,structprebor_stu*);//7---查询图书的编号图书的信息,并输出
voidchaxun2_(structbooklist*,structprebor_stu*,structborrow*);//7---按作者查询信息并输出
voidchaxun3_(structbooklist*,structprebor_stu*,structborrow*);//7---查询某类别图书信息并自动输出
voidchaxun4_(structborrow*,prebor_stu*,structbooklist*);//7---按学号查询借阅信息
structbooklist*shanchu(structbooklist*,structborrow*,structprebor_stu*);//9---删除数据
structborrow*shanchu2_(structborrow*,structborrow*);//删除一个structborrow结构体的数据
structprebor_stu*shanchu3_(structprebor_stu*,structprebor_stu*);//删除一个structprebor_stu结构体的数据
voidxiugai(structbooklist*,structborrow*,structprebor_stu*);//10---修改数据
voidborstore(structborrow*borrow_head);//保存已借阅图书信息到文件borrowlist.txt
//重新保存修改后的预借阅信息到文件prebor_stulist.txt(全部覆盖)
voidprestore(structprebor_stu*pre_head);
structborrow*borload(void);//从文件提取信息创建已借阅图书源信息链表
structbooklist*charu(structbooklist*head,structborrow*borrow_head);//8---将图书的数据到顺序排放的链表中,且插入后也是顺序排放的
structbooklist*scanf1_(void);//输入单个图书源数据
voidexchange(structbooklist*,structbooklist*);//交换两个结构体内的内容
structborrow*tianjia1_(structborrow*borrow_head,structbooklist*p);//添加一个structborrow结构体的数据
intmain(void){
intn,n1,x,k=0,flag,flag1,x1;
charch;
structbooklist*head=NULL;//图书信息链表头指针
structborrow*borrow_head=NULL;//已借阅图书信息链表头指针
structprebor_stu*pre_head=NULL;//预借图书信息链表头指针
flag1=0;x=x1=1;
while(x)
{
system("cls");
printf("***************************************************************************\n");
printf("*>>>>>>>>>>>>>欢迎使用君宁图书管理系统<<<<<<<<<<<<<<<*\n");
printf("*0---退出系统5---从文件录入数据*\n");
printf("*1---录入数据6---统计库存数*\n");
printf("*2---输出信息10---修改数据7---查询功能*\n");
printf("*3---按价格排序8---增加数据*\n");
printf("*4---按编号排序9---删除数据*\n");
printf("***************************************************************************\n");
printf("请选择功能:
");
scanf("%d",&n);
getchar();
switch(n)
{
case0:
//0---退出系统
{
x=0;
printf("*******谢谢使用君宁图书管理系统!
******\n");
printf("******欢迎下次使用!
******\n");
break;
}
case1:
//1---录入数据
{
while(x1)
{
system("cls");
printf("*******欢迎使用君宁图书信息录入系统*******\n");
printf("***0---放弃录入****\n");
printf("**1---录入图书源信息**\n");
printf("*2---录入借出图书信息*\n");
printf("**3---录入预借图书信息**\n");
printf("********祝您使用愉快********\n");
printf("请选择功能:
");
scanf("%d",&n1);
getchar();
switch(n1)
{
case0:
{
x1=0;
break;
}
case1:
{
head=create();/*创建图书信息链表*/
printf("是否将源图书信息保存到文件booklist.txt!
...(Y/N):
");
ch=getchar();
if(ch=='y'||ch=='Y')
store(head);
getchar();
break;
}
case2:
{
if(head==NULL)
{
printf("请先录入图书源信息!
\n");
getchar();
break;
}
else
{
borrow_head=borrow_creat(head);//创建已借阅图书信息链表
printf("是否将源图书信息保存到文件borrowlist.txt!
...(Y/N):
");
ch=getchar();
if(ch=='y'||ch=='Y')
borstore(borrow_head);
getchar();
break;
}
}
case3:
{
if(head==NULL)
{
printf("请先录入图书源信息!
\n");
getchar();
break;
}
else
{
flag=pre_creat(head);
if(flag==1)
printf("没有录入预借图书信息!
\n\n");
if(flag==2)