应用程序设计:图书管理系统模板(链表+文件)

本文介绍了一个图书管理系统的概览,系统涵盖了图书库存、借阅和读者信息管理。功能包括资料的增删改查、借还操作、读者等级设定以及统计分析。管理员账号为admin。
摘要由CSDN通过智能技术生成

概述
        主要包括图书的库存信息,每一本书的借阅信息以及每一个人的借书信息。
系统功能:
    (1)借阅资料管理(对相关资料进行添加,删除,修改,查询等操作)
    (2)借阅管理(包括借出操作,还书操作)
    (3)读者管理(读者等级:可分为教师,学生。并定义每类读者可借书数量)
    (4)统计分析(当前借阅和相关资料状态。统计分析借阅排行榜,资料状态统计,借阅统计,显示所有至当日到期未还书信息等功能分析)

如果觉得链表麻烦的话可以使用(数组+文件):https://blog.csdn.net/qq_30253757/article/details/85341155

管理员用户名和密码都是admin

//
// Created by JBC33 on 2019/12/16.
//


#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cstring>
#include <windows.h>
#include <ctime>
#include <cstdlib>
using namespace std;
typedef struct books //书籍编号————(作者,名称,出版时间,价格)与书籍编号一一对应,否则为新一类书
{                    //数量
    int book_id;
    char author[50], book_name[50];
    int time, count;
    double price;
    struct books *next;
} BOOK, *Pbook;
typedef struct have_been_borrowed //已借出的图书信息,书籍编号,借书编号,借书数量,书名,所借人的账号名
{
    int book_id;
    int borrowed_book_id;
    int count;
    char book_name[50];
    char student_id[50];
    struct have_been_borrowed *next;
} BORROW, *Pborrow;
typedef struct users //用户信息:用户id,账户名,密码,所借书的上限
{
    long long int user_id;
    char user_name[50];
    char passwd[50];
    int book_limit;
    int job;
    struct users *next;
} USERS, *Pusers;
Pusers user_now = NULL;
/**************************以下为函数声明**********************************/
void user_error();                                                                          //无用户信息的错误提示
int read_books_information_to_file(Pbook head, Pborrow head2, Pusers head3);                //文件的读取
void welcome();                                                                             //欢迎界面
void null_error();                                                                          //图书库为空的报错信息
void list_borrow(Pborrow head);                                                             //打印已借图书信息
void addbook(struct books *head);                                                           //添加书籍信息
void list(Pbook head);                                                                      //打印所有书籍信息
int search(Pbook head);                                                                     //搜寻书籍信息
int modify(Pbook p);                                                                        //搜寻结束后可进行查找
int del(Pbook before, Pbook will_be_del);                                                   //删除该图书信息
int borrow(Pbook head, Pborrow borrowed);                                                   //借书功能
void return_book_list(Pborrow head, Pbook origin);                                          //还书的列表(便于控制函数的调用)
int return_book(Pborrow head_list, Pbook origin);                                           //还书功能
int return_book_by_student_id(Pborrow head, Pbook origin);                                  //通过学号还书
void add_borrow(Pbook d, Pborrow head, int a, int b, int c, char name[], char book_name[]); //已借的书的添加
void borrowor(Pbook head, Pborrow borrowed);                                                //借书菜单
void del_user(Pusers head);                                                                 //删除用户
int add_users(Pusers head);                                                                 //增加用户
void user_list(Pusers head);                                                                //打印所有用户信息
int user_manage(Pusers head);                                                               //用户管理主列表
int save_books_information_to_file(Pbook head, Pborrow head2, Pusers head3);                //文件的保存
/**************************以上为函数声明**********************************/
/***************************图书基础功能***********************************/
int read_books_information_to_file(Pbook head, Pborrow head2, Pusers head3)
{
    FILE *p = fopen("books_information.dat", "r"), *q = fopen("borrowed_books.dat", "r");
    FILE *u = fopen("users_information.dat", "r");
    if (p == NULL || q == NULL || u == NULL)
    {
        cout << "文件不存在。。。" << endl
             << "已重建相关文件" << endl;
        system("pause");
        system("cls");
        return 1;
    }
    Pbook books_head = head;
    Pborrow borrowed_head = head2;
    Pusers users_head = head3;
    int a, b, k;
    char name[50];
    char author[50];
    double price;
    while (fscanf(p, "%d%s%s%d%lf%d", &a, name, author, &k, &price, &b) != EOF)
    {
        Pbook before = (Pbook)malloc(sizeof(BOOK));
        before->book_id = a;
        strcpy(before->book_name, name);
        strcpy(before->author, author);
        before->count = b;
        before->time = k;
        before->price = price;
        books_head->next = before;
        before->next = NULL;
        books_head = before;
    }
    int c, d, e;
    char borrow_name[50];
    char student_id[50];
    while (fscanf(q, "%d%s%d%d%s", &c, borrow_name, &d, &e, &student_id) != EOF)
    {
        Pborrow after = (Pborrow)malloc(sizeof(BORROW));
        after->book_id = c;
        strcpy(after->book_name, borrow_name);
        after->borrowed_book_id = d;
        after->count = e;
        strcpy(after->student_id, student_id);
        borrowed_head->next = after;
        after->next = NULL;
        borrowed_head = after;
    }
    long long user_id;
    char user_name[50];
    char passwd[50];
    int book_limit;
    int job;
    while (fscanf(u, "%lld%s%s%d%d", &user_id, user_name, passwd, &book_limit,&job) != EOF)
    {
        Pusers english = (Pusers)malloc(sizeof(USERS));
        english->user_id = user_id;
        strcpy(english->user_name, user_name);
        strcpy(english->passwd, passwd);
        english->book_limit = book_limit;
        english->job=job;
        users_head->next = english;
        english->next = NULL;
        users_head = english;
    }
    fclose(p);
    fclose(q);
    fclose(u);
    return 0;
}
int save_books_information_to_file(Pbook head, Pborrow head2, Pusers head3)
{
    system("cls");
    FILE *p = fopen("books_information.dat", "w");
    FILE *bore = fopen("borrowed_books.dat", "w");
    FILE *u = fopen("users_information.dat", "w");
    if (p == NULL )
    {
        cout << "打开文件失败!!!,请重试。。。" << endl;
        return 1;
    }
    if ( bore == NULL)
    {
        cout << "打开文件失败!!!,请重试。。。" << endl;
        return 1;
    }
    if ( u == NULL)
    {
        cout << "打开文件失败!!!,请重试。。。" << endl;
        return 1;
    }
    Pbook q = head->next;
    Pborrow w = head2->next;
    Pusers eng = head3->next;
    cout << "正在写入文件,请稍后。。。" << endl;
    Sleep(1500);
    while (q != NULL)
    {
        fprintf(p, "%d %s %s %d %f %d\n", q->book_id, q->book_name, q->author, q->time, q->price, q->count);
        q = q->next;
    }
    while (w != NULL)
    {
        fprintf(bore, "%d %s %d %d %s\n", w->book_id, w->book_name, w->borrowed_book_id, w->count, w->student_id);
        w = w->next;
    }
    while (eng != NULL)
    {
        fprintf(u, "%lld %s %s %d %d\n", eng->user_id, eng->user_name, eng->passwd, eng->book_limit,eng->job);
        eng = eng->next;
    }
    system("cls");
    cout << "写入完成。请稍后。。。" << endl;
    fclose(p);
    fclose(bore);
    fclose(u);
    return 0;
}
void list_borrow(Pborrow head)
{
    if (head->next == NULL)
    {
        sys
C语言写的课程设计: 图书管理系统 系统功能主要管理图书库存信息图书借阅信息以及借阅者的借书信息每一图书库存信息包括编号、书名、作者、出版社、出版日期、金额、类别、总入库数量、当前库存量、已借出本数等。每一本被借阅的书都包括如下信息:编号、书名、金额、借书证号、借书日期、到期日期、罚款金额等。每一个人的借书信息包括借书证号、姓名、班级、学号等。 系统详细功能如下: 1)借阅资料管理 要求把书籍、期刊、报刊分类管理,并可以随时对其相关资料进行添加、删除、修改、查询等操作。 2)借阅管理:借出操作、还书操作、续借处理 以上处理需要互相配合以及赔、罚款金额的编辑等操作完成图书借还业务的各种登记。例如:读者还书时不仅更新图书库存信息,还应该自动计算该书应罚款金额。并显示该读者所有至当日内到期未还书信息。 3)读者管理 读者等级:对借阅读者进行分类处理,例如可分为教师和学生两类。并定义每类读者的可借书数量和相关的借阅时间等信息。 读者管理:对读者信息可以录入,并且可对读者进行挂失或注销、查询等服务的作业。 4)统计分析 随时可以进行统计分析,以便及时了解当前的借阅情况和相关的资料状态,统计分析包括借阅排行榜、资料状态统计和借阅统计、显示所有至当日内到期未还书信息等功能分析。 5)系统参数设置:可以设置相关的罚款金额,最多借阅天数等系统服务器参数。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值