C语言图书管理系统源代码.docx

上传人:b****6 文档编号:5097501 上传时间:2022-12-13 格式:DOCX 页数:35 大小:21.04KB
下载 相关 举报
C语言图书管理系统源代码.docx_第1页
第1页 / 共35页
C语言图书管理系统源代码.docx_第2页
第2页 / 共35页
C语言图书管理系统源代码.docx_第3页
第3页 / 共35页
C语言图书管理系统源代码.docx_第4页
第4页 / 共35页
C语言图书管理系统源代码.docx_第5页
第5页 / 共35页
点击查看更多>>
下载资源
资源描述

C语言图书管理系统源代码.docx

《C语言图书管理系统源代码.docx》由会员分享,可在线阅读,更多相关《C语言图书管理系统源代码.docx(35页珍藏版)》请在冰豆网上搜索。

C语言图书管理系统源代码.docx

C语言图书管理系统源代码

#include<>

#include<>

#include<>

structtushu{/*图书结构体*/

charnum[10];/*编号*/

charname[20];/*书名*/

charwriter[20];/*作者*/

charpress[20];/*出版社*/

charkind[20];/*类别*/

doubletime;/*时间*/

doubleprice;/*价格*/

structtushu*next;

};

structstu/*学生结构体*/

{

intsnum;/*学号*/

charmima[10];/*密码*/

structstu*next;

};

FILE*fp;/*图书文件*/

FILE*fp1;/*管理员信息文件*/

FILE*fp2;/*学生信息文件*/

voidmenu();/*管理员主菜单(管理员进入对图书及学生信息进行管理操作)*/

voidxmenu();/*学生主菜单(学生进入可对图书,密码进行操作)*/

voidgfind();/*管理员查询(管理员可按一定的方式查询图书)*/

voidxfind();/*学生查询(学生可按一定的方式查询图书)*/

voidsecret();/*管理员权限(管理员登陆所用,输入错误次数过多自动退出)*/

voidsort();/*排序(管理员可按一定的方式对图书进行排序,排序完之后可选择文件进行保存)*/

voidfprint(structtushu*head);/*保存(可追加的保存,如添加可用)*/

voidfprint_(structtushu*head);/*保存(可覆盖保存如修改,删除,排序后用)*/

voidhfprint(structtushu*head);/*还书保存(还书成功后自动保存到文件)*/

voidjfprint_(structtushu*head);/*借书保存(借书成功之后自动从图书馆删除)*/

structtushu*Input();/*图书添加(可进行图书的添加)*/

structtushu*create();/*从文件创建链表(从文件中读出信息,建立单链表)*/

voidgBrowse(structtushu*head);/*管理员浏览(对图书进行遍历)*/

voidxBrowse(structtushu*head);/*学生浏览(学生对图书进行遍历)*/

voidcount(structtushu*head);/*统计数量(管理员可对图书进行统计)*/

voidFindofname(structtushu*head);/*按书名查找*/

voidFindofwriter(structtushu*head);/*按作者查找*/

voidFindofkind(structtushu*head);/*按类别查找*/

voidxFindofname(structtushu*head);/*学生按书名查找*/

voidxFindofwriter(structtushu*head);/*学生按作者查找*/

voidxFindofkind(structtushu*head);/*学生按类别查找*/

voidSort_time(structtushu*head);/*按时间排序(管理员按时间对图书进行排序,排序完之后可选择文件进行保存)*/

voidSort_price(structtushu*head);/*按价格排序*/

voidSort_num(structtushu*head);/*按编号排序*/

voidDelete(structtushu*head,charm[15]);/*按编号删除(管理员可按编号删除图书)*/

voidRevise(structtushu*head);/*修改(管理员可对图书进行修改,并选择是否保存)*/

voidborrow(structtushu*head);/*借书*/

voidhuanshu();/*还书(学生借完书之后进行还书,若没有图书则不能借)*/

voidgxinxi();/*管理员信息(有管理员的账号及密码,可进行修改)*/

voidxmima(structstu*head1);/*学生密码修改(学生可对自己的密码进行修改)*/

structstu*xcreate();/*从文件创建学生信息(从文件读出学生信息,建立学生链表)*/

voidxsecret(structstu*head1);/*学生权限(学生登陆所用)*/

voidmenu()/*管理员主菜单(管理员进入对图书及学生信息进行管理操作)*/

{

intchoice,n=0;

structtushu*head;

structstu*head1,*p;

charm[15];

there:

printf("┏━┓━━━━━━━━━━━━━━━━━━━┏━┓\n");

printf("┃┃socat图书管理系统┃┃\n");

printf("┃┗━━━━━━━━━━━━━━━━━━━┛┃\n");

printf("┃●[0]退出系统┃\n");

printf("┃┃\n");

printf("┃●[1]帮助┃\n");

printf("┃┃\n");

printf("┃●[2]浏览图书┃\n");

printf("┃┃\n");

printf("┃●[3]统计图书数目┃\n");

printf("┃┃\n");

printf("┃●[4]查询┃\n");

printf("┃┃\n");

printf("┃●[5]添加┃\n");

printf("┃┃\n");

printf("┃●[6]排序┃\n");

printf("┃┃\n");

printf("┃●[7]修改┃\n");

printf("┃┃\n");

printf("┃●[8]删除┃\n");

printf("┃┃\n");

printf("┃●[9]修改账号及密码┃\n");

printf("┃┃\n");

printf("┃●[10]学生信息┃\n");

printf("┗━━━━━━━━━━━━━━━━━━━━━━━┛\n");

printf("请选择:

");

fflush(stdin);

head=create();

scanf("%d",&choice);

if(choice==1)

{

/2.否):

");

scanf("%d",&x);

if(x==1)

fprint(head);

else

{

system("cls");

printf("\n\n\n\t\t\t文件没有被保存!

\n\n\n\n");

system("pause");

system("cls");

menu();

}

}

voidfprint(structtushu*head)

{

structtushu*p1;

if((fp=fopen("","a"))==NULL)

{

printf("Fileopenerror!

\n");

exit(0);

}

if(head==NULL)

{

printf("没有图书保存!

\n");

system("pause");

system("cls");

menu();

}

for(p1=head;p1!

=NULL;p1=p1->next)/*遍历*/

fprintf(fp,"%s\t%s\t%s\t%s\t%s\t%.0lf\t%lf\n",p1->num,p1->name,p1->writer,p1->press,p1->kind,p1->time,p1->price);/*将图书信息写入文件*/

fclose(fp);

system("cls");

printf("\n图书信息已成功保存到文件中!

\n");

system("pause");

system("cls");

getchar();

menu();

}

voidfprint_(structtushu*head)

{

structtushu*p1;

chara[20];

printf("请输入你保存的文件!

\n");

scanf("%s",a);

if((fp=fopen(a,"w"))==NULL)

{

printf("Fileopenerror!

\n");

exit(0);

}

if(head==NULL)

{

system("cls");

printf("没有图书!

\n");

system("pause");

system("cls");

menu();

}

for(p1=head;p1!

=NULL;p1=p1->next)

fprintf(fp,"%s\t%s\t%s\t%s\t%s\t%.0lf\t%lf\n",p1->num,p1->name,p1->writer,p1->press,p1->kind,p1->time,p1->price);/*将图书信息写入文件*/

fclose(fp);

system("cls");

printf("\n图书信息已成功保存到文件%s中!

\n",a);

system("pause");

system("cls");

menu();

}

voidhfprint(structtushu*head)

{

structtushu*p1;

if((fp=fopen("","a"))==NULL)

{

printf("Fileopenerror!

\n");

exit(0);

}

if(head==NULL)

{

printf("没有还书!

\n");

xmenu();

}

for(p1=head;p1!

=NULL;p1=p1->next)/*遍历*/

fprintf(fp,"%s\t%s\t%s\t%s\t%s\t%.0lf\t%lf\n",p1->num,p1->name,p1->writer,p1->press,p1->kind,p1->time,p1->price);/*将图书信息写入文件*/

fclose(fp);

xmenu();

}

voidjfprint_(structtushu*head)

{

structtushu*p1;

if((fp=fopen("","w"))==NULL)

{

printf("Fileopenerror!

\n");

exit(0);

}

if(head==NULL)

{

xmenu();

}

for(p1=head;p1!

=NULL;p1=p1->next)

{

fprintf(fp,"%s\t%s\t%s\t%s\t%s\t%.0lf\t%lf\n",p1->num,p1->name,p1->writer,p1->press,p1->kind,p1->time,p1->price);/*将图书信息写入文件*/

}

fclose(fp);

system("cls");

getchar();

xmenu();

}

structtushu*create()

{

structtushu*head=NULL,*p,*p1,*p2;

if((fp=fopen("","r"))==NULL)/*先安全打开目录文件*/

{

printf("Fileopenerror!

\n");

exit(0);

}

while(!

feof(fp))/*读取并创建链表*/

{

p=(structtushu*)malloc(sizeof(structtushu));

p->price=-1;

fscanf(fp,"%s%s%s%s%s%lf%lf",p->num,p->name,p->writer,p->press,p->kind,&p->time,&p->price);

if(p->price==-1)

{

free(p);

break;

}

if(head==NULL)

{

head=p;

p1=p;

p1->next=NULL;

}

else

{

p1->next=p;

p2=p1;

p1=p;

p1->next=NULL;

}

}

fclose(fp);

returnhead;

}

voidgBrowse(structtushu*head)

{

structtushu*p1;

for(p1=head;p1!

=NULL;p1=p1->next)

{

printf("编号书名作者出版社类别出版时间价格\n");

printf("%s\t%s\t%s\t%s\t%s\t%.0lf\t%.2lf\n",p1->num,p1->name,p1->writer,p1->press,p1->kind,p1->time,p1->price);

}

system("pause");

system("cls");

menu();

}

voidxBrowse(structtushu*head)

{

structtushu*p1;

for(p1=head;p1!

=NULL;p1=p1->next)

{

printf("编号书名作者出版社类别出版时间价格\n");

printf("%s\t%s\t%s\t%s\t%s\t%.0lf\t%.2lf\n",p1->num,p1->name,p1->writer,p1->press,p1->kind,p1->time,p1->price);

}

system("pause");

system("cls");

xmenu();

}

voidcount(structtushu*head)/*统计图书数目*/

{

intn=0;

structtushu*p1;

for(p1=head;p1!

=NULL;p1=p1->next)

n++;

printf("\n此系统统计在内的图书共有%d册。

\n",n);/*计算并输出图书数目*/

system("pause");

system("cls");

menu();

}

voidFindofname(structtushu*head)/*按书名查询图书*/

{

inti=0,n;

charb[20];

structtushu*p;

p=head;

printf("\n请输入要查询的图书名称:

");

scanf("%s",b);

while(p!

=NULL)

{

if(strcmp(p->name,b)==0)

{

printf("\n编号书名作者出版社类别出版时间价格\n");

printf("%s\t%s\t%s\t%s\t%s\t%.0lf\t%.2lf\n",p->num,p->name,p->writer,p->press,p->kind,p->time,p->price);

i++;

}

p=p->next;

}

if(i==0)

{

system("cls");

printf("\n对不起!

没有找到名为《%s》的图书!

\n",b);

system("pause");

}

printf("\n\n\n\t\t\t是否继续查找图书信息(1.是/其他.返回):

");

scanf("%d",&n);

if(n==1)

gfind();

else

{

system("cls");

menu();

}

}

voidFindofwriter(structtushu*head)

{

inti=0,n;

charb[20];

structtushu*p;

p=head;

printf("\n请输入要查询的图书作者姓名:

");

scanf("%s",b);

while(p!

=NULL)

{

if(strcmp(p->writer,b)==0)

{

printf("\n编号书名作者出版社类别出版时间价格\n");

printf("%s\t%s\t%s\t%s\t%s\t%.0lf\t%.2lf\n",p->num,p->name,p->writer,p->press,p->kind,p->time,p->price);

i++;

}

p=p->next;

}

if(i==0)

{

system("cls");

printf("\n对不起!

没有找到‘%s’所著的相关图书!

\n",b);

system("pause");

}

printf("\n\n\n\t\t\t是否继续查找图书信息(1.是/其他.返回):

");

scanf("%d",&n);

if(n==1)

gfind();

else

{

system("cls");

menu();

}

}

voidFindofkind(structtushu*head)

{

inti=0,n;

charb[20];

structtushu*p;

p=head;

printf("\n请输入您要查询的图书类别:

");

scanf("%s",b);

while(p!

=NULL)

{

if(strcmp(p->kind,b)==0)

{

printf("\n编号书名作者出版社类别出版时间价格\n");

printf("%s\t%s\t%s\t%s\t%s\t%.0lf\t%.2lf\n",p->num,p->name,p->writer,p->press,p->kind,p->time,p->price);

i++;

}

p=p->next;

}

if(i==0)

{

system("cls");

printf("\n对不起!

没有找到类别为‘%s’的图书!

\n",b);

system("pause");

}

printf("\n\n\n\t\t\t是否继续查找图书信息(1.是/其他.返回):

");

scanf("%d",&n);

if(n==1)

gfind();

else

{

system("cls");

menu();

}

}

voidxFindofname(structtushu*head)/*按书名查询图书*/

{

inti=0,n;

charb[20];

structtushu*p;

p=head;

printf("\n请输入要查询的图书名称:

");

scanf("%s",b);

while(p!

=NULL)

{

if(strcmp(p->name,b)==0)

{

printf("\n编号书名作者出版社类别出版时间价格\n");

printf("%s\t%s\t%s\t%s\t%s\t%.0lf\t%.2lf\n",p->num,p->name,p->writer,p->press,p->kind,p->time,p->price);

i++;

}

p=p->next;

}

if(i==0)

{

system("cls");

printf("\n对不起!

没有找到名为《%s》的图书!

\n",b);

system("pause");

}

printf("\n\n\n\t\t\t是否继续查找图书信息(1.是/其他.返回):

");

scanf("%d",&n);

if(n==1)

xfind();

else

{

system("cls");

xmenu();

}

}

voidxFindofwriter(structtushu*head)

{

inti=0,n;

charb[20];

structtushu*p;

p=head;

printf("\n请输入要查询的图书作者姓名:

");

scanf("%s",b);

while(p!

=NULL)

{

if(strcmp(p->writer,b)==0)

{

printf("\n编号书名作者出版社类别出版时间价格\n");

printf("%s\t%s\t%s\t%s\t%s\t%.0lf\t%.2lf\n",p->num,p->name,p->writer,p->press,p->kind,p->time,p->price);

i++;

}

p=p->next;

}

if(i==0)

system("cls");

printf("\n对不起!

没有找到‘%s’所著的相关图书!

\n",b);

system("pause");

printf("\n\n\n\t\t\t是否继续查找图书信息(1.是/其他.返回):

");

scanf("%d",&n);

if(n==1)

xfind();

else

{

system("cls");

xmenu();

}

}

voidxFindofkind(structtushu*head)

{

inti=0,n;

charb[20];

structtushu*p;

p=head;

printf("\n请输入您要查询的图书类别:

");

scanf("%s",b);

while(p!

=NULL)

{

if(strcmp(p->kind,b)==0)

{

prin

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

当前位置:首页 > 高等教育 > 军事

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

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