图书馆管理系统源代码

上传人:m**** 文档编号:506489795 上传时间:2023-10-02 格式:DOC 页数:14 大小:48KB
返回 下载 相关 举报
图书馆管理系统源代码_第1页
第1页 / 共14页
图书馆管理系统源代码_第2页
第2页 / 共14页
图书馆管理系统源代码_第3页
第3页 / 共14页
图书馆管理系统源代码_第4页
第4页 / 共14页
图书馆管理系统源代码_第5页
第5页 / 共14页
点击查看更多>>
资源描述

《图书馆管理系统源代码》由会员分享,可在线阅读,更多相关《图书馆管理系统源代码(14页珍藏版)》请在金锄头文库上搜索。

1、/*我的图书管理文档*#include#include#includeFILE *fp; /*定义全局变量fp*/struct bookschar number20; /*图书编号*/char name20; /*图书名称*/char writer20; /*作者*/char press20; /*出版社*/char kind20; /*类别*/double time; /*出版时间*/double price; /*价格*/struct books *next; /*指向下一结点*/;/*函数申明*/void secret(); /*密码验证*/void menu(); /*主菜单*/str

2、uct books * Input(); /*录入图书信息*/void fprint(struct books *head); /*将信息导入文件可追加*/void fprint1(struct books *head); /*将信息导入文件只写(可覆盖)*/struct books * create(struct books * head,int *n); /*从文件中读取数据构建链表*/void Browse(struct books *head); /*浏览全部图书信息*/void count(struct books *head); /*统计图书数目*/void seekbyname(

3、struct books *head); /*按书名查询图书*/void seekbywriter(struct books *head); /*按作者查询图书*/void rankbytime(struct books * head); /*按出版时间排序*/void rankbyprice(struct books * head); /*按价格排序*/struct books * Delete(struct books * head,char a20); /*按编号删除图书*/struct books * Revise(struct books *head); /*修改图书*/*密码验证*

4、/void secret()int a;int b=601;int c=632;printf(请输入您的学号后三位:);scanf(%d,&a);if(a=b&c=a)printf( 欢迎进入图书管理系统n);elseprintf( 对不起!您输入的密码有误,请查证后再输!n); exit(0);/*主菜单*/void menu()printf(*n); printf( 图书管理系统 n);printf(*-*n);printf( * 0-退出系统 * * 4-按作者查询 *n);printf( * 1-添加图书 * * 5-按时间排序 *n);printf( * 2-浏览图书 * * 6-按

5、价格排序 *n);printf( * 3-按书名查询 * * 7-删除 *n); printf( 8-修改 *n); printf(*-*n); printf(*n); /*录入图书信息建立图书信息的链表*/struct books * Input()struct books *p1,*p2,*head; /*建立辅助结点及头结点*/char number;int n=0,x;system(cls);menu();printf(请按对应项输入图书信息以0结束!n);printf(n);printf(编号 书名 作者 价格 出版社 类别 出版时间 n);printf(n);p1=(struct

6、books *)malloc(sizeof(struct books);head=p2=p1;do /*使用do while语句输入图书信息*/scanf(%s,&p1-number);if(strcmp(p1-number,0)=0) /*判断结束符*/break; elsescanf(%s%s%s%s%lf%lf,p1-name,p1-writer,p1-press,p1-kind,&p1-time,&p1-price);number=0; p1=(struct books *)malloc(sizeof(struct books);p2-next=p1;p2=p1;n+;while(1)

7、;p1-next=NULL;getchar(); /*数据被存放在链表中*/ printf(n 1 保存图书信息 n); printf(n 2 不保存图书信息 n);scanf(%d,&x);if(x=1)fprint(head); /*调用函数保存至文件*/elseprintf(n文件没有被保存!n);return head; /*返回头指针*/*将信息导入文件可追加*/void fprint(struct books *head)FILE *fp;struct books *p1;if(fp=fopen(books.txt,a)=NULL)printf(File open error!n)

8、;exit(0);for(p1=head;p1-next!=NULL;p1=p1-next) /*遍历*/fprintf(fp,%st%st%st%st%st%.0lft%lfn,p1-number,p1-name,p1-writer,p1-press,p1-kind,p1-time,p1-price);/*将图书信息写入文件*/fclose(fp); system(cls); /*清屏函数*/menu();printf(n图书已成功保存!n);getchar();/*将信息导入文件*/void fprint1(struct books *head)FILE *fp;struct books

9、*p1;if(fp=fopen(books.txt,w)=NULL)printf(File open error!n);exit(0);for(p1=head;p1!=NULL;p1=p1-next) /*遍历*/fprintf(fp,%st%st%st%st%st%.0lft%lfn,p1-number,p1-name,p1-writer,p1-press,p1-kind,p1-time,p1-price);/*将图书信息写入文件*/fclose(fp); /*关闭文件*/system(cls);menu();printf(n图书已成功保存!n);getchar();/*从文件中读取数据构建链表*/struct books * create(struct books * head,int *n)struct books *p,*p1,*p2;if(fp=fopen(books.txt,a+)=NULL) /*先安全打开目录文件*/printf(File open error!n);exit(0);while(!feof(

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 机械/制造/汽车 > 汽车技术

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号