C++ 部署小型图书管理系统

Hi!大家好,这里是霍田的博客!

最近学校里组织了一场跨学科,我也发现了表现契机:图书管理系统(Book Managerment System)。

于是就"小小的"编写了一下,目前共191行,包含开始页面+美化+版本号+增加书籍+查找书籍+借阅图书+还回图书,(注意:帮助及删除图书暂未支持,请理性选择)。

C++语言编写:

cpp 复制代码
#include <bits/stdc++.h>
using namespace std;

char x;
int book_count = 0, jieyue_count = 0;
struct Books {
    char program[3];
    string name;
    int in_school_year;
    char where_fangwei, where_xingzhuang, where_build, where_book_count[4];
    int where_hang, where_lie, where_floor, many = 0;
    int out_book = 0;
} a[9999999];

struct Jieyue {
    char program[11][3];
    string book_name[11];
    int in_school_year[11];
    char where_fangwei[11], where_xingzhuang[11], where_build[11], where_book_count[11][4];
    int where_hang[11], where_lie[11], where_floor[11];
    string name;
    int book_number = 0;
} people[500500];

inline void plus_book() {
    printf("请输入书籍信息(例如:LS 2022J 3NZ 5 4 001 西安故事 2):\n");
    ++book_count;
    cin >> a[book_count].program[1] >> a[book_count].program[2] >> a[book_count].in_school_year >> a[book_count].where_build >> a[book_count].where_floor >> a[book_count].where_fangwei >> a[book_count].where_xingzhuang >> a[book_count].where_lie >> a[book_count].where_hang >> a[book_count].where_book_count[1] >> a[book_count].where_book_count[2] >> a[book_count].where_book_count[3];
    scanf(" ");
    cin >> a[book_count].name >> a[book_count].many;
    printf("输入信息成功\n");
    cout << a[book_count].program[1] << a[book_count].program[2] << a[book_count].in_school_year << a[book_count].where_build << a[book_count].where_floor << a[book_count].where_fangwei << a[book_count].where_xingzhuang << a[book_count].where_lie << a[book_count].where_hang << a[book_count].where_book_count[1] << a[book_count].where_book_count[2] << a[book_count].where_book_count[3];
    cout << a[book_count].name << a[book_count].many;
    cout << endl;
    return;
}

inline void find_book() {
    printf("请输入查找书籍名称:\n");
    string find_name;
    scanf("\n");
    cin >> find_name;
    bool can_find = false;
    for (int i = 1; i <= book_count; i++) {
        if (a[i].name == find_name) {
            cout << a[book_count].where_build << a[book_count].where_floor << a[book_count].where_fangwei << a[book_count].where_xingzhuang << a[book_count].where_lie << a[book_count].where_hang << a[book_count].where_book_count[1] << a[book_count].where_book_count[2] << a[book_count].where_book_count[3];
            cout << a[book_count].name << a[book_count].many << endl;
            can_find = true;
        }//cout << a[i].program[1] << a[i].program[2] << a[i].in_school_year << a[i].where_build << a[i].where_floor << a[i].where_fangwei << a[i].where_xingzhuang << a[i].where_lie << a[i].where_hang << a[i].where_book_count[1] << a[i].where_book_count[2] << a[i].where_book_count[3] << a[i].name << "\n";
            
    }
    if (!can_find) {
        cout << "对不起,目前暂无您要查找的书籍。\n";
    }
    return;
}

inline void take_out() {
    printf("请输入您的名字:\n");
    jieyue_count++;
    cin >> people[jieyue_count].name;
    printf("\n请输入借阅本数:\n");
    int book_much = 0;
    cin >> book_much;
    printf("\n请输入您要借阅的书籍名称:\n");
    for (int i = 1; i <= book_much; i++) {
        string find_name;
        scanf("\n");
        cin >> find_name;
        bool can_find = false;
        for (int j = 1; j <= book_count; j++) {
            if (a[j].name == find_name && (a[j].out_book <= a[j].many && a[j].many >= 1)) {
                people[jieyue_count].book_number++;
                cout << a[j].program[1] << a[j].program[2] << a[j].in_school_year << a[j].where_build << a[j].where_floor << a[j].where_fangwei << a[j].where_xingzhuang << a[j].where_lie << a[j].where_hang << a[j].where_book_count[1] << a[j].where_book_count[2] << a[j].where_book_count[3] << a[j].name << "\n";
                people[jieyue_count].program[people[jieyue_count].book_number][1] = a[j].program[1];
                people[jieyue_count].program[people[jieyue_count].book_number][2] = a[j].program[2];
                people[jieyue_count].in_school_year[people[jieyue_count].book_number] = a[j].in_school_year;
                people[jieyue_count].where_build[people[jieyue_count].book_number] = a[j].where_build;
                people[jieyue_count].where_fangwei[people[jieyue_count].book_number] = a[j].where_fangwei;
                people[jieyue_count].where_xingzhuang[people[jieyue_count].book_number] = a[j].where_xingzhuang;
                people[jieyue_count].where_book_count[people[jieyue_count].book_number][1] = a[j].where_book_count[1];
                people[jieyue_count].where_book_count[people[jieyue_count].book_number][2] = a[j].where_book_count[2];
                people[jieyue_count].where_book_count[people[jieyue_count].book_number][3] = a[j].where_book_count[3];
                people[jieyue_count].where_floor[people[jieyue_count].book_number] = a[j].where_floor;
                people[jieyue_count].where_hang[people[jieyue_count].book_number] = a[j].where_hang;
                people[jieyue_count].where_lie[people[jieyue_count].book_number] = a[j].where_lie;
                can_find = true;
                a[j].out_book++;
                a[j].many--;
                break;
            }
        }
        if (!can_find) {
            cout << "对不起,您要借阅的书籍暂无。\n";
        }
        else if (people[jieyue_count].book_number == 10) {
            cout << "您的借阅最大书籍数限制已到。\n";
        }
        else {
            cout << "您要借阅的书籍已经被设为"借阅"模式!\n";
        }
    }
    return;
}

inline void turn_back(){
    printf("请输入您的名字:\n");
    jieyue_count++;
    cin >> people[jieyue_count].name;
    printf("\n请输入还回本数:\n");
    int book_much = 0;
    cin >> book_much;
    printf("\n请输入您要还回的书籍名称:\n");
    for (int i = 1; i <= book_much; i++) {
        string find_name;
        scanf("\n");
        cin >> find_name;
        bool can_find = false;
        for (int j = 1; j <= book_count; j++) {
            if (a[j].name == find_name && (a[j].out_book == true)) {
                people[jieyue_count].book_number--;
                cout << a[j].program[1] << a[j].program[2] << a[j].in_school_year << a[j].where_build << a[j].where_floor << a[j].where_fangwei << a[j].where_xingzhuang << a[j].where_lie << a[j].where_hang << a[j].where_book_count[1] << a[j].where_book_count[2] << a[j].where_book_count[3] << a[j].name << "\n";
                people[jieyue_count].program[people[jieyue_count].book_number][1] = 0;
                people[jieyue_count].program[people[jieyue_count].book_number][2] = 0;
                people[jieyue_count].in_school_year[people[jieyue_count].book_number] = 0;
                people[jieyue_count].where_build[people[jieyue_count].book_number] = 0;
                people[jieyue_count].where_fangwei[people[jieyue_count].book_number] = 0;
                people[jieyue_count].where_xingzhuang[people[jieyue_count].book_number] = 0;
                people[jieyue_count].where_book_count[people[jieyue_count].book_number][1] = 0;
                people[jieyue_count].where_book_count[people[jieyue_count].book_number][2] = 0;
                people[jieyue_count].where_book_count[people[jieyue_count].book_number][3] = 0;
                people[jieyue_count].where_floor[people[jieyue_count].book_number] = 0;
                people[jieyue_count].where_hang[people[jieyue_count].book_number] = 0;
                people[jieyue_count].where_lie[people[jieyue_count].book_number] = 0;
                can_find = true;
                a[j].out_book--;
                a[j].many++;
                break;
            }
        }
        if (!can_find) {
            cout << "对不起,您似乎没有借阅这本书。";
        } else if (people[jieyue_count].book_number == 0) {
            cout << "您目前已还回所有书籍。\n";
        } else {
            cout << "您要还回的书籍已经被设为"馆藏"模式!\n";
        }
    }
    return;
}

inline void hello_window(){
    printf("\t\t    欢迎来到浐灞三小图书管理系统 \t\t\n");
    printf("\t Welcome to Chanbasanxiao Books Management System\t\t\n");
    printf("\t\t 信息组成员 监制 CBSX-BMS(CBMS)制作组 制作\t\t\n");
    printf("\t\t   Version/版本:CBMS 1.0 正式版 \t\t\n");
    printf("\t\t    Tips:暂不支持"删除图书" \t\t\n");
    printf("\n");
    printf("\t\t\t 录入图书请按1 \t\t\n");
    printf("\t\t\t 查找图书请按2 \t\t\n");
    printf("\t\t\t 借阅图书请按3 \t\t\n");
    printf("\t\t\t 还回图书请按4 \t\t\n");
    //printf("\t\t\t 删除图书请按5 \t\t\n");
    //printf("\t\t\t 需要帮助请按# \t\t\n");
    printf("\t\t\t *_* 欢迎使用 \t\t\n");
    printf("\n");
    cin >> x;
    if (x == '#') {
        // call();
    }
    else if (x == '1') {
        plus_book();
    }
    else if (x == '2') {
        find_book();
    }
    else if (x == '3') {
        take_out();
    }
    else if (x == '4') {
        turn_back();
    }
    else if (x == '5') {
        // delete_book();
    }
    hello_window();
}

int main(){
    hello_window();
}

本代码仅供学习使用,禁止搬运至其他文章,感谢配合。

相关推荐
ywwwwwwv6 小时前
力扣300
算法·leetcode·职场和发展
惊鸿.Jh6 小时前
若依自定义后端接口404踩坑记录
java·开发语言
缺点内向6 小时前
C# 中如何从 URL 下载 Word 文档:基于 Spire.Doc 的高效解决方案
开发语言·c#·word
源码获取_wx:Fegn08956 小时前
基于springboot + vue考勤管理系统
java·开发语言·vue.js·spring boot·后端·spring·课程设计
weixin_307779136 小时前
Jenkins声明式管道扩展点API:深度解析与应用指南
开发语言·ci/cd·自动化·jenkins·etl
认真敲代码的小火龙6 小时前
【JAVA项目】基于JAVA的仓库管理系统
java·开发语言·课程设计
来自于狂人6 小时前
HCIE云计算超长考点精析
算法·贪心算法·云计算
Code_Geo6 小时前
JAVA大数据场景使用StreamingOutput
java·大数据·开发语言·streamingoutput