C语言程序设计-图书管理系统

上传人:赵****学 文档编号:144506155 上传时间:2020-09-09 格式:DOC 页数:14 大小:88.55KB
返回 下载 相关 举报
C语言程序设计-图书管理系统_第1页
第1页 / 共14页
C语言程序设计-图书管理系统_第2页
第2页 / 共14页
C语言程序设计-图书管理系统_第3页
第3页 / 共14页
C语言程序设计-图书管理系统_第4页
第4页 / 共14页
C语言程序设计-图书管理系统_第5页
第5页 / 共14页
点击查看更多>>
资源描述

《C语言程序设计-图书管理系统》由会员分享,可在线阅读,更多相关《C语言程序设计-图书管理系统(14页珍藏版)》请在金锄头文库上搜索。

1、图书馆管理系统C语言程序设计图书馆管理系统1、 分析过程 首先此程序需要实现输入、增加、删除、查询、输出的五大功能,则首先需要设置一个菜单键,让用户可以选择不同的功能,完成不同的操作,然后编写不同的函数实现不同的功能,在这个过程中注意要人性化,让用户方便,直观的进行操作。二、算法 三、函数模块介绍 1录入模块:本模块主要执行信息的录入功能 2浏览模块:本模块主要是执行把已有信息输出浏览功能 3查询模块:本模块主要是按照图书名查找图书的相关信息 4删除模块:主要是执行删除图书信息的功能 5退出模块:方便用户离开4、 源程序#include#include#include#include stru

2、ct books_list char author20; /*作者名*/ char bookname20; /*书名*/ char publisher20; /*出版单位*/ char pbtime15; /*出版时间*/ char loginnum10; /*登陆号*/ float price; /*价格*/ char classfy10; /*分类号*/ struct books_list * next; /*链表的指针域*/; struct books_list * Create_Books_Doc(); /*新建链表*/void InsertDoc(struct books_list

3、* head); /*插入*/void DeleteDoc(struct books_list * head , int num);/*删除*/void Print_Book_Doc(struct books_list * head);/*浏览*/void search_book(struct books_list * head); /*查询*/void save(struct books_list * head);/*保存数据至文件*/ /*新建链表头节点*/struct books_list * Create_Books_Doc() struct books_list * head; he

4、ad=(struct books_list *)malloc(sizeof(struct books_list); /*分配头节点空间*/ head-next=NULL; /*头节点指针域初始化,定为空*/ return head; /*保存数据至文件*/void save(struct books_list * head) struct books_list *p; FILE *fp; p=head; fp=fopen(data.txt,w+); /*以写方式新建并打开 data.txt文件*/ fprintf(fp,n); /*向文件输出表格*/ fprintf(fp,登录号 书 名 作

5、者 出版单位 出版时间 分类号 价格 n); fprintf(fp,n); /*指针从头节点开始移动,遍历至尾结点,依次输出图书信息*/ while(p-next!= NULL) p=p-next; fprintf(fp,%-6.6s%-10.10s%-10.10s%-10.10s%-12.12s%-6.6s%.2f n,p-loginnum,p-bookname,p-author,p-publisher,p-pbtime,p-classfy,p-price); fprintf(fp,n); fclose(fp); printf( 已将图书数据保存到 data.txt 文件n); /*插入*/

6、void InsertDoc(struct books_list *head) /*定义结构体指针变量 s指向开辟的新结点首地址 p为中间变量*/ struct books_list *s, *p; char flag=Y; /*定义flag,方便用户选择重复输入*/ p=head; /*遍历到尾结点,p指向尾结点*/ while(p-next!= NULL) p=p-next; /*开辟新空间,存入数据,添加进链表*/ while(flag=Y|flag=y) s=(struct books_list *)malloc(sizeof(struct books_list); printf(n

7、请输入图书登陆号:); fflush(stdin); scanf(%s,s-loginnum); printf(n 请输入图书书名:); fflush(stdin); scanf(%s,s-bookname); printf(n 请输入图书作者名:); fflush(stdin); scanf(%s,s-author); printf(n 请输入图书出版社:); fflush(stdin); scanf(%s,s-publisher); printf(n 请输入图书出版时间:); fflush(stdin); scanf(%s,s-pbtime); printf(n 请输入图书分类号:); f

8、flush(stdin); scanf(%s,s-classfy); printf(n 请输入图书价格:); fflush(stdin); scanf(%f,&s-price); printf(n); p-next=s; /*将新增加的节点添加进链表*/ p=s; /*p指向尾节点,向后移*/ s-next=NULL; printf( 添加成功!); printf(n 继续添加?(Y/N):); fflush(stdin); scanf(%c,&flag); printf(n); if(flag=N|flag=n) break; else if(flag=Y|flag=y) continue;

9、 save(head); /*保存数据至文件*/ return; /*查询操作*/ void search_book(struct books_list *head) struct books_list * p; char temp20; p=head; if(head=NULL | head-next=NULL) /*判断数据库是否为空*/ printf( 图书库为空!n); else printf(请输入您要查找的书名: ); fflush(stdin); scanf(%s,temp); /*指针从头节点开始移动,遍历至尾结点,查找书目信息*/ while(p-next!= NULL) p

10、=p-next; if(strcmp(p-bookname,temp)=0) printf(n图书已找到!n); printf(n); printf(登录号: %stn,p-loginnum); printf(书名: %stn,p-bookname); printf(作者名: %stn,p-author); printf(出版单位: %stn,p-publisher); printf(出版时间: %stn,p-pbtime); printf(分类号: %stn,p-classfy); printf(价格: %.2ftn,p-price); if(p-next=NULL) printf(n查询完毕!n); return; /*浏览操作*/ void Print_Book_Doc(struct books_list * head) struct books_list * p; if(head=NULL | head-next=NULL) /*判断数据库是否为空*/ printf(n 没有图书记录! nn); return; p=head; printf(n); printf(登录号 书 名 作 者 出版单位 出版时间 分类号 价格 n); printf(n); /*指针从头节点开始移动,遍历至尾结点,依次输出图书信息*/ w

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

当前位置:首页 > 大杂烩/其它

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