图书管理系统的设计(C语言)_第1页
图书管理系统的设计(C语言)_第2页
图书管理系统的设计(C语言)_第3页
图书管理系统的设计(C语言)_第4页
图书管理系统的设计(C语言)_第5页
已阅读5页,还剩9页未读 继续免费阅读

付费下载

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

图书管埋系统设计

图书管理信息包括:图书名称、图书编号、单价、作者、存在状态、借书人姓名、性别、学

号等

功能描述:

1.新进熟土基本信息的输入

2.图书基本信息的查询

3.对撤销图书信息的删除

4.为借书人办理注册

5.办理借书手续

6.办理换书手续

要求:以文件方式存储数据,系统以菜单方式工作。

这是本人大一第二学期初C语言课程设计的作品,嘿嘿,本来以为已经找不到原稿了,今天

无意中居然在QQ网络硬盘中找到了当初的teta版,发布于此,以作记念。

C源代码如口

include<stdio。h)

#include<stdliboh>

include(string。h>

structbook{

charbook_name130];

intbianhao;

doubleprice:

charauthor[20]:

charstate[20];

charname[20];

charsex[10];

intxuehao:

structbook*booknext:

};

structclub{

charname[20];

charsex[10];

intxuehao;

charborrowI301:

structclub*club_next:

):

voidPrint_Book(structbook*head_book):/*浏览所有图书信息*/

voidPrint_Club(structclub*head_club);/*浏览所有会员信息*/

structbook*Create_Nev/_Book();/*创建新的图书库,图书编号输入为。时结束*/

structbook*Search_Book_bianhao(intbianhao,structbook*head_book);

structbook*Search_Book_name(char*b_name,structbook*head_book);

structbook*Search_Bookj)rice(doubleprice_h,doublepricej,structbook*head_book);

structbook*lnsert_Book(structbook*head_book,structbook*stud_book);/*增力ll图书,逐个

添加*/

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*lnsert_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,pricej;

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");

printfC'™一一乂向导]-------->[新建图书库]\n\n");

printf("注意:当输入图书编号为0时,进入下一步

head_book=Create_New_Book();

system(“cls”);

printfCn欢迎您第一次进入图书管理系统!\n\n");

printfC'-->[向导]一一->[新建会员库]\n\n”);

printf("注意:当输入会员学号为0时,进入主菜单.\n\n");

head_club=Create_New_Club0;

system(”cls");

do{

printf("\n\t\t\t=====四书管理系统=====\n\n”);

printf("\n,,);

printf⑴:借书办理\t");printf("⑹:还书办理\n”);

printf(^n");

printfC\t\t\t[2]:查询图书\t”);printf。[7]:查询会员\n”);

printf(w\t\t\t[3]:添加图书\t");printf("网:添加会员\n”);

printf("\t\t\t[4]:删除图书\t");printf("[91:删除会员\n");

printf("\t\t\t[5]:遍历图书\t");printf("[10]:遍历会员\n\n");

printf("\t\t\t================\n\nv);

prinUCNMO:退出\n\n");

printfC请选择〈0'10〉:”);

scanf("%d”,&choice);

switch(choice){

case1:

printf("\n\t\t\t=====图书管理系统=====\n\n");

printf("输入所借图书编号:\nM);

scant("%d”,&bianhao);

printf("输入借书人的学号:\n”);

scant("%d",&xuehao);

head_book=Lent_Book(bianhao,xuehao,head_book,head_club);

system("cis");

printf(M\n借阅成功!\n\r"):

printf("相关信息如下:\n\n");

head_book=Search_Book_bianhao(bianhao,head_book):

break:

case2:

system("cis");

printf("\n\t\t\t=====弱书管理系统=====\n\n");

printf("1o按编号查询\n\n");

printf(”2。按名称查询\n\n");

printf("3.按价格区间查询\n\n");

printf("0.返回主菜单\n\n”);

printf("请选择:”);

scant&f);

if(f==1){

printf(”请输入查询图书编号>);

scanf("%d",&bianhao);

printf("相关信息如下:\n\nw);

head_book=Search_Book_bianhao(bianhao,head_book);

break:

)

elseif(f==2){

b_name=book_name;

getchar();

printf(”请输入查询图书名称:");

gets(b_name);

printf("相关信息如下:\n\n");

headJx)ok=Search_Bcx)k_name(b_naine,head_book);

break:

)

elseif(f==3){

printf("请输入最高价格

scanf("%lf”,&price_h);

printf("请输入最低价格:");

scantC,%lf',&priceJ);

printf("相关信息如下:\n\n");

head_book=Search_Book_price(price_h,price_l,head_book);

break;

)

elseif(f==O){

break:

)

break;

case6:

printf("\n\t\t\t=====图书管理系统=====\n\n"卜

printf(M输入所还图书编号:\n");

scanf("%d",&bianhao);

printf(M输入还书人的学号:\n");

scanf("%d",&xuehao);

headbook=back(bianhao,xjehao,headbook,head_club);

system(“cis");

printf(')n归还成功!\n\n");

printf("相关信息如下:\n\n");

head_book=Search_Book_bianhao(bianhao,head_book):

break:

case3:

system("cis");

printf("\n\t\t\t=====图书管理系统=====\n\n");

printf("请输入图书名称:");

scant("%s”,book_name);

printf("请输入图书编号:");

scanf(”%d”,&bianhao):

printf("请输入单价:”);

scanf(n%lf\&price):

printf("请输入作者名字「);

scantauthor);

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_bouk=(slruclbook.*)nialloc(size_buuk);

strcpy(p_book—>book_name,book_name);

pbook-)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=lnsert_Book(head_book,p_book);

printfC\n添加图书成功!\n\n"):

)

break;

case4:

syslemC^cIs");

printf("\n\t\t\t=====图书管理系统=====\n\n");

printf("输入删除图书编号:\n");

scanfC%d",&bianhao);

head_book=Delete_Book(head_book,bianhao);

printf("\0删除图书成功!\n\n");

break;

case5:

system(“cls");

printf("\n\t\t\t=====图书管理系统=====\n\n”।;

Print_Book(head_book);

break:

case7:

system("cis");

printf("\n\t\忖=====图书管理系统=====\n\n");

printfC1o按学号查询\n\n"):

printf(”2o按姓名查询\n'n");

printf("Oo返回主菜单\n\n");

printf("请选择:”卜

scanf("%d”,&f);

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==O){

break:

)

break;

printf("请输入查询会员学号:\n");

scanf("%d”,&xuehao):

printf("相关信息如下:\n\n");

break;

case8:

systcm(“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(pclub-)name,name);

strcpy(p_club-)sex,sex);

pclub—>xuehao=xuehao;

strcpy(p_club—)borrow,v暂无”);

head_club=lnsert_Club(head_club,p_club);

printf('M添加会员成功!\n\n");

)

break;

case9:

system(“cls");

printf("\n\t\t\t=====图书管理系统=====\n\n"):

printf("输入要删除会员学号:\n");

,&xuehao);

head_club=Delete_Club(head_club,xuehao);

printf("\n删除会员成功!^n\n"):break;

case10:

system("cis");

printf("\n\t\t\t=====图书管理系统=====\n\n");

Print_Club(head_club);break:

caseO:

system("cls");

printf("\n\t\t\t=====图书管理系统=====\n\n"):

printf('Vi谢谢您的使用!\r\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("请输入图书名称:");

scanfC%s",book_name);

printff请输入图书编号:”);

scanf("%d”,&bianhao);

printf("请输入单价:");

scant("%If",&price):

printf("请输入作者名字:");

scant("%s",author);

printf("\n");

whilefbianhao!=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,aulhor);

strcpy(p_book—)state,"存在”);

strcpy(p_book->sex,“待定”);

strcpy(p_book->name,"待定”);

head_book=lnsert_Book(head_book,p_book);

printf("请输入图书名称:”);

scarJ("%ti",buuk_rtarile);

printT请输入图书编号:”);

scant("%d”,&bianhao);

printf("请输入单价:");

scant(u%lf\&price):

printf("请输入作者名字:");

,,

scanf("%s”,author);printf('\n);

)

returnhead_book;

)

structbook*Search_Book_bianhao(intbianhao,structbook*head_book)

(

structbook*ptr_book:intflag=O;

for(ptr_book=head_book;otr_book;ptrbook=ptr_book-)book_next)

(

if(ptr_book->bianhao==bianhao){

printf("图书编号:%d\n",ptr_book—>bianhao);

printf("图书名称:%s\n,otr_book—>book_name);

printf(”图书单价:%.2型n*ptr_book,price);

printf("图书作者:%s\n",p1r_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);

prinif("\n");flag++;

)

)

if(flag==O){printf("暂无此图书信息!\n\n");)

returnhead_book;

)

structbook*Search_Book_name(char*b_name,structbook*head_book)

(

structbook*ptr_book;

intflag=O;

for(ptr_book=head_book;ptr_book;ptr_book=ptrbook—>book_next)

jI

if(strcmp(ptr_book—)book_name.b_name)==0){

printf("图书编号:%d\n",ptr_book->bianhao);

printf("图书名称:%s\rT,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);

prinl1(学号:%d\n",plr_buok—>xuehao);

printf("\n");

flag++;

)

)

则ag==O){printf("暂无此图书信息!\n\nM);)

returnhead_book;

)

structbook*Search_Book_price(doubleprice_h,doubleprioe_l,structbook*head_book)

(structbook*ptr_book;

intflag=O;

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(w图书编号:%d\n",ptr_book->bianhao);

printf("图书名称:%s\n,r,ptr_book—)book_name);

printf("图书单价:%。2lf\nw,ptrbook-)price);

printf("图书作者:%s\n",ptr_book—>author);

printf("存在状态:%s\n",ptr_book->state);

printf(M借书人姓名:%s\n",ptr_book-)name);

printf(借书人性别:%s\n",ptr_book->sex);

printf("学号:%d\n",ptr_book—)xuehao);

printf("\n");

flag++;

)

)

if(flag==O){printf("暂无此图书信息!\n\n");)

returnhead_book;

)

structbook*Delete_Book(structbook*head_book,intbianhao)

(

structbook*ptr1_book,*ptr2_book;

while(head_book!=NULL&&head_book一)bianhao==bianhao){

ptr2_book=head_book;

head_book=head_book->book_next:

free(ptr2_book);

)

if(head_book==NULL)returnNULL;

ptr1_book=head_book;

ptr2_book=head_book—>book_next;

while(ptr2_book!=NULL){

if(ptr2_book—>bianhao==bianhao){

ptr1_book->boo<next=ptr2_book—)book_next;

free(ptr2_book);

)

else

ptr1_book=ptr2_book;

ptr2_book=ptr1_book-)booknext;

)

returnhead_book;

)

structclub*Create_New_Club()

{structclub*head_club,*p_club:

intxuehao;

charname[20],sex^10];

intsize_club=sizeof(struc:club):

head_club=NULL;

printf(”请输入会员名字:");scanf("%s",name);

printf(”请输入会员性别:");scanf("%s",sex);

printf("请输入会员学号:");scanf("%d",&xuehao);

printf("\n");

while(xuehao!=0){

p_club=(structclub*)malloc(size_club):

strcpy(p_dub)name,name):

strcpy(p_club—)sex,sex);p_clut>-)xuehao=xuehao:

strcpy(p_club—>borrow,“暂无");

head_club=lnsert_Club(head_club,p_club);

printf(”请输入会员名字:H);

scanf("%s",name);

printf(”请输入会员性别:");scanf(J,%s",sex);

printf("请输入会员学号:"):scanf("%d",&xuehao):

printf("\rT):

)

returnhead_club;

)

structclub*Search_Club_xjehao(intxuehao,structclub*head_club)

{structclub*ptr_club;

intflag=O;

for(ptr_club=head_club:ptr_club;ptr_club=ptr_club->club_next)

(

if(ptr_club—>xuehao==xuehao){

printf("会员姓名会s\n,ptr_club->name);

printf。会员性另ij:%s\nn,ptr_club—>sex);

printf("会员学号:%d\n",ptr_club->xuehao);

printf("所借图书:%s\nw,ptr_club—>borrow);

printf("\n");flag++:

)}

if(flag==O){printf(”此用户不存在!\n\n"):}

returnhead_club;

)

structclub*SearchClubname(char*c_name»structclub*head_club)

{

structclub*ptr_club;intflag=O;

for(ptr_club=head_club;ptr_club;ptr_club=ptr_club->club_next)

(

if(strcmp(ptr_club—>name,c_name)==0){

printf(M会员姓名:%s\n>>,ptr_club-)name);

printf("会员性别:%s\n",ptr_club—>sex);

printf(w会员学号:%d\nw,ptr_club->xuehao);

printf("所借图书:%s\n",ptr_club—>borrow);

printf(^n");flag++;}

)

if(flag==0){printf("此用户不存在!\n\n");)

returnhead_club;

)

structbook*Lent_Book(intbianhaojntxuehao,structbook*head_book,structclub

*head_club)

{structbook*ptr_book;

structclub*ptr_club;

intflag=O;

for(ptr_book=head_book;ptr_book;ptr_book=ptr_book—>book_next)

for(ptr_club=head_club;ptr_club;ptr_club=ptr_club—>club_next)

(

if((ptr_book—>bianhao==bianhao)&&(ptr_club—>xuehao==xuehao))

{strcpy(ptrbook—)name,ptrclub->name);/*字符串的更制,把右边的内容复制到左边文

/

strcpy(ptr_book—>sex,ptr_club->sex);

ptr_book->xuehao=ptr_club-)xuehao:

strcpy(ptjbook—>state,"暂无");

strcpy(ptr_club—>borrow,ptr_book—>book_name);flag++;}

if(flag==O){printf暂无比图书或者您还未注册为会员!\n\n");}

)

returnhead_book:

)

structbook*back(intbianhao.intxuehao,structbook*head_book,structclub*head_dub)

{structbook*ptr_book;structclub*ptr_club;

intflag=O;

for(ptr_book=head_book;ptr_book;ptr_book=ptr_book-〉book_next)

for(ptr_club=head_club;ptr_club;ptr_club=ptr_club->club_next)

(

if((ptr_book-)bianhao==bianhao)&&(ptr_club-)xuehao==xuehao))

{strcpy(ptr_book—>name,"暂无"):strcpy(ptr_book->sex,“待定");

plr_bouk->xuehau=O,

strcpy(ptr_book—>state,w暂无”);

strcpy(ptr_club—>borrow,M暂无");

flag++;}

if(flag==O){printf("输入有误,请重试\n\n");}

)

returnhead_book;

)

structbook*lnsert_Book(structbook*headbook,structbook*studbook)

{structbookwptr_b,*ptr1_b,*ptr2_b;

ptr2_b=head_book;ptr_b=stud_book;

if(head_book==NULL){

head_book=ptr_b:

head_book-)book_next=NULL;

)

else{

while((ptr_b->bianhao>ptr2_b—)bianhao)&&(ptr2_b->book_next!=NULL)){

ptr1_b=ptr2_b;ptr2_b=ptr2_b->book_next;

)

if(ptr_b—>bianhao<=ptr2_b->bianhao){

if(head_book==ptr2_b)nead_book=ptr_b;

elseptr1_b->book_next=ptr_b:

ptr_b->book_next=ptr2_b;

)

else{

ptr2_b->book_next=ptr_b;

ptr_b->book_next=NULL;

)

)

returnhead_book;

)

structclub*lnsert_Club(structclub*head_club,structclub*stud_club)

{struc

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论