图书管理系统设计C语言.docx
《图书管理系统设计C语言.docx》由会员分享,可在线阅读,更多相关《图书管理系统设计C语言.docx(25页珍藏版)》请在冰豆网上搜索。
图书管理系统设计C语言
图书管理系统设计
图书管理信息包括:
图书名称、图书编号、单价、作者、存在状态、借书人姓名、性别、学号等
功能描述:
1.新进熟土基本信息地输入
2.图书基本信息地查询
3.对撤消图书信息地删除
4.为借书人办理注册
5.办理借书手续
6.办理换书手续
要求:
以文件方式存储数据,系统以菜单方式工作.
这是本人大一第二学期初C语言课程设计地作品,嘿嘿,本来以为已经找不到原稿了,今天无意中竟然在QQ网络硬盘中找到了当初地teta版,发布于此,以作纪念.
C源代码如下:
#include
#include
#include
structbook{
charbook_name[30]。
intbianhao。
doubleprice。
charauthor[20]。
charstate[20]。
charname[20]。
charsex[10]。
intxuehao。
structbook*book_next。
}。
structclub{
charname[20]。
charsex[10]。
intxuehao。
charborrow[30]。
structclub*club_next。
}。
voidPrint_Book(structbook*head_book>。
/*浏览所有图书信息*/
voidPrint_Club(structclub*head_club>。
/*浏览所有会员信息*/
structbook*Create_New_Book(>。
/*创建新地图书库,图书编号输入为0时结束*/
structbook*Search_Book_bianhao(intbianhao,structbook*head_book>。
structbook*Search_Book_name(char*b_name,structbook*head_book>。
structbook*Search_Book_price(doubleprice_h,doubleprice_l,structbook*head_book>。
structbook*Insert_Book(structbook*head_book,structbook*stud_book>。
/*增加图书,逐个添加*/
structbook*Delete_Book(structbook*head_book,intbianhao>。
/*删除图书*/
structclub*Create_New_Club(>。
structclub*Search_Club_xuehao(intxuehao,structclub*head_club>。
structclub*Search_Club_name(char*c_name,structclub*head_club>。
structclub*Insert_Club(structclub*head_club,structclub*stud_club>。
structclub*Delete_Club(structclub*head_club,intxuehao>。
structbook*Lent_Book(intbianhao,intxuehao,structbook*head_book,structclub*head_club>。
structbook*back(intbianhao,intxuehao,structbook*head_book,structclub*head_club>。
intmain(>
{
structbook*head_book,*p_book。
charbook_name[30],name[20],author[20],sex[10]。
intbianhao。
doubleprice,price_h,price_l。
intsize_book=sizeof(structbook>。
intm=1,n=1,f。
char*b_name,*c_name。
structclub*head_club,*p_club。
intxuehao。
intsize_club=sizeof(structclub>。
intchoice。
printf("\n欢迎您第一次进入图书管理系统!
\n\n">。
printf("----->[向导]----->[新建图书库]\n\n">。
printf("注意:
当输入图书编号为0时,进入下一步.\n\n">。
head_book=Create_New_Book(>。
system("cls">。
printf("\n欢迎您第一次进入图书管理系统!
\n\n">。
printf("----->[向导]----->[新建会员库]\n\n">。
printf("注意:
当输入会员学号为0时,进入主菜单.\n\n">。
head_club=Create_New_Club(>。
system("cls">。
do{
printf("\n\t\t\t〓〓〓〓〓图书管理系统〓〓〓〓〓\n\n">。
printf("\n">。
printf("\t\t\t[1]:
借书办理\t">。
printf("[6]:
还书办理\n">。
printf("\n">。
printf("\t\t\t[2]:
查询图书\t">。
printf("[7]:
查询会员\n">。
printf("\t\t\t[3]:
添加图书\t">。
printf("[8]:
添加会员\n">。
printf("\t\t\t[4]:
删除图书\t">。
printf("[9]:
删除会员\n">。
printf("\t\t\t[5]:
遍历图书\t">。
printf("[10]:
遍历会员\n\n">。
printf("\t\t\t〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓\n\n">。
printf("\t\t\t0:
退出\n\n">。
printf("请选择<0~10>:
">。
scanf("%d",&choice>。
switch(choice>{
case1:
printf("\n\t\t\t〓〓〓〓〓图书管理系统〓〓〓〓〓\n\n">。
printf("输入所借图书编号:
\n">。
scanf("%d",&bianhao>。
printf("输入借书人地学号:
\n">。
scanf("%d",&xuehao>。
head_book=Lent_Book(bianhao,xuehao,head_book,head_club>。
system("cls">。
printf("\n借阅成功!
\n\n">。
printf("相关信息如下:
\n\n">。
head_book=Search_Book_bianhao(bianhao,head_book>。
break。
case2:
system("cls">。
printf("\n\t\t\t〓〓〓〓〓图书管理系统〓〓〓〓〓\n\n">。
printf("1.按编号查询\n\n">。
printf("2.按名称查询\n\n">。
printf("3.按价格区间查询\n\n">。
printf("0.返回主菜单\n\n">。
printf("请选择:
">。
scanf("%d",&f>。
if(f==1>{
printf("请输入查询图书编号:
">。
scanf("%d",&bianhao>。
printf("相关信息如下:
\n\n">。
head_book=Search_Book_bianhao(bianhao,head_book>。
break。
}
elseif(f==2>{
b_name=book_name。
getchar(>。
printf("请输入查询图书名称:
">。
gets(b_name>。
printf("相关信息如下:
\n\n">。
head_book=Search_Book_name(b_name,head_book>。
break。
}
elseif(f==3>{
printf("请输入最高价格:
">。
scanf("%lf",&price_h>。
printf("请输入最低价格:
">。
scanf("%lf",&price_l>。
printf("相关信息如下:
\n\n">。
head_book=Search_Book_price(price_h,price_l,head_book>。
break。
}
elseif(f==0>{
break。
}
break。
case6:
printf("\n\t\t\t〓〓〓〓〓图书管理系统〓〓〓〓〓\n\n">。
printf("输入所还图书编号:
\n">。
scanf("%d",&bianhao>。
printf("输入还书人地学号:
\n">。
scanf("%d",&xuehao>。
head_book=back(bianhao,xuehao,head_book,head_club>。
system("cls">。
printf("\n归还成功!
\n\n">。
printf("相关信息如下:
\n\n">。
head_book=Search_Book_bianhao(bianhao,head_book>。
break。
case3:
system("cls">。
printf("\n\t\t\t〓〓〓〓〓图书管理系统〓〓〓〓〓\n\n">。
printf("请输入图书名称:
">。
scanf("%s",book_name>。
printf("请输入图书编号:
">。
scanf("%d",&bianhao>。
printf("请输入单价:
">。
scanf("%lf",&price>。
printf("请输入作者名字:
">。
scanf("%s",author>。
printf("\n">。
structbook*ptr_b。
for(ptr_b=head_book。
ptr_b。
ptr_b=ptr_b->book_next>
{
if(ptr_b->bianhao==bianhao>
{
printf("此编号图书已存在\n">。
m=0。
break。
}
}
if(m>{
p_book=(structbook*>malloc(size_book>。
strcpy(p_book->book_name,book_name>。
p_book->bianhao=bianhao。
p_book->price=price。
p_book->xuehao=0。
strcpy(p_book->author,author>。
strcpy(p_book->state,"存在">。
strcpy(p_book->sex,"待定">。
strcpy(p_book->name,"待定">。
head_book=Insert_Book(head_book,p_book>。
printf("\n添加图书成功!
\n\n">。
}
break。
case4:
system("cls">。
printf("\n\t\t\t〓〓〓〓〓图书管理系统〓〓〓〓〓\n\n">。
printf("输入删除图书编号:
\n">。
scanf("%d",&bianhao>。
head_book=Delete_Book(head_book,bianhao>。
printf("\n删除图书成功!
\n\n">。
break。
case5:
system("cls">。
printf("\n\t\t\t〓〓〓〓〓图书管理系统〓〓〓〓〓\n\n">。
Print_Book(head_book>。
break。
case7:
system("cls">。
printf("\n\t\t\t〓〓〓〓〓图书管理系统〓〓〓〓〓\n\n">。
printf("1.按学号查询\n\n">。
printf("2.按姓名查询\n\n">。
printf("0.返回主菜单\n\n">。
printf("请选择:
">。
scanf("%d",&f>。
if(f==1>{
printf("请输入查询会员学号:
">。
scanf("%d",&xuehao>。
printf("相关信息如下:
\n\n">。
head_club=Search_Club_xuehao(xuehao,head_club>。
break。
}
elseif(f==2>{
c_name=name。
getchar(>。
printf("请输入查询会员姓名:
">。
gets(c_name>。
printf("相关信息如下:
\n\n">。
head_club=Search_Club_name(c_name,head_club>。
break。
}
elseif(f==0>{
break。
}
break。
printf("请输入查询会员学号:
\n">。
scanf("%d",&xuehao>。
printf("相关信息如下:
\n\n">。
break。
case8:
system("cls">。
printf("\n\t\t\t〓〓〓〓〓图书管理系统〓〓〓〓〓\n\n">。
printf("请输入会员名字:
">。
scanf("%s",name>。
printf("请输入会员性别:
">。
scanf("%s",sex>。
printf("请输入会员学号:
">。
scanf("%d",&xuehao>。
printf("\n">。
structclub*ptr_c。
for(ptr_c=head_club。
ptr_c。
ptr_c=ptr_c->club_next>
{
if(ptr_c->xuehao==xuehao>
{printf("此学号会员已存在\n">。
n=0。
break。
}
}
if(n>{
p_club=(structclub*>malloc(sizeof(structclub>>。
strcpy(p_club->name,name>。
strcpy(p_club->sex,sex>。
p_club->xuehao=xuehao。
strcpy(p_club->borrow,"暂无">。
head_club=Insert_Club(head_club,p_club>。
printf("\n添加会员成功!
\n\n">。
}
break。
case9:
system("cls">。
printf("\n\t\t\t〓〓〓〓〓图书管理系统〓〓〓〓〓\n\n">。
printf("输入要删除会员学号:
\n">。
scanf("%d",&xuehao>。
head_club=Delete_Club(head_club,xuehao>。
printf("\n删除会员成功!
\n\n">。
break。
case10:
system("cls">。
printf("\n\t\t\t〓〓〓〓〓图书管理系统〓〓〓〓〓\n\n">。
Print_Club(head_club>。
break。
case0:
system("cls">。
printf("\n\t\t\t〓〓〓〓〓图书管理系统〓〓〓〓〓\n\n">。
printf("\n谢谢您地使用!
\n\n">。
break。
}
}while(choice!
=0>。
return0。
}
structbook*Create_New_Book(>
{
structbook*head_book,*p_book。
intbianhao。
doubleprice。
charbook_name[30],author[20]。
intsize_book=sizeof(structbook>。
head_book=NULL。
printf("请输入图书名称:
">。
scanf("%s",book_name>。
printf("请输入图书编号:
">。
scanf("%d",&bianhao>。
printf("请输入单价:
">。
scanf("%lf",&price>。
printf("请输入作者名字:
">。
scanf("%s",author>。
printf("\n">。
while(bianhao!
=0>{
p_book=(structbook*>malloc(size_book>。
strcpy(p_book->book_name,book_name>。
p_book->bianhao=bianhao。
p_book->price=price。
p_book->xuehao=0。
strcpy(p_book->author,author>。
strcpy(p_book->state,"存在">。
strcpy(p_book->sex,"待定">。
strcpy(p_book->name,"待定">。
head_book=Insert_Book(head_book,p_book>。
printf("请输入图书名称:
">。
scanf("%s",book_name>。
printf("请输入图书编号:
">。
scanf("%d",&bianhao>。
printf("请输入单价:
">。
scanf("%lf",&price>。
printf("请输入作者名字:
">。
scanf("%s",author>。
printf("\n">。
}
returnhead_book。
}
structbook*Search_Book_bianhao(intbianhao,structbook*head_book>
{
structbook*ptr_book。
intflag=0。
for(ptr_book=head_book。
ptr_book。
ptr_book=ptr_book->book_next>
{
if(ptr_book->bianhao==bianhao>{
printf("图书编号:
%d\n",ptr_book->bianhao>。
printf("图书名称:
%s\n",ptr_book->book_name>。
printf("图书单价:
%.2lf\n",ptr_book->price>。
printf("图书作者:
%s\n",ptr_book->author>。
printf("存在状态:
%s\n",ptr_book->state>。
printf("借书人姓名:
%s\n",ptr_book->name>。
printf("借书人性别:
%s\n",ptr_book->sex>。
printf("学号:
%d\n",ptr_book->xuehao>。
printf("\n">。
flag++。
}
}
if(flag==0>{printf("暂无此图书信息!
\n\n">。
}
returnhead_book。
}
structbook*Search_Book_name(char*b_name,structbook*head_book>
{
structbook*ptr_book。
intflag=0。
for(ptr_book=head_book。
ptr_book。
ptr_book=ptr_book->book_next>
{
if(strcmp(ptr_book->book_name,b_name>==0>{
printf("图书编号:
%d\n",ptr_book->bianhao>。
printf("图书名称:
%s\n",ptr_book->book_name>。
printf("图书单价:
%.2lf\n",ptr_book->price>。
printf("图书作者:
%s\n",ptr_book->author>。
printf("存在状态:
%s\n",ptr_book->state>。
printf("借书人姓名:
%s\n",ptr_book->name>。
printf("借书人性别:
%s\n",ptr_book->sex>。
printf("学号:
%d\n",ptr_book->xuehao>。
printf("\n">。
flag++。
}
}
if(flag==0>{printf("暂无此图书信息!
\n\n">。
}
returnhead_book。
}
structbook*Search_Book_price(doubleprice_h,doubleprice_l,structbook*head_book>
{structbook*ptr_book。
intflag=0。
for(ptr_book=head_book。
ptr_book。
ptr_book=ptr_book->book_next>
{
if((ptr_book->price>=price_l>&&(ptr_book->price<=price_h>>{
printf("图书编号:
%d\n",ptr_book->bianhao>。
printf("图书名称:
%s\n",ptr_book->book_name>。
printf("图书单价:
%.2lf\n",ptr_book->price>。
printf("图书作者:
%s\n",ptr_book->author>。
printf("存在状态:
%s\n",ptr_book->state>。
printf("借书人姓名:
%s\n",ptr_book->name>。
printf("借书人性别:
%s\n",ptr_book->sex>。
printf("学号:
%d\n",ptr_book->xuehao>。
printf("\n">。
flag++。
}
}
if(flag==0>{printf("暂无此图书信息!
\n\n">。
}
returnhead_book。
}
structbook*Delete_Book(structbook*head_book,intbianhao>
{
structbook