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();
}

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

相关推荐
碧海银沙音频科技研究院42 分钟前
炬芯ATS3089X手表的HFP通话不自动路由到设备BT的问题解决
网络·人工智能·嵌入式硬件·算法
Joy T2 小时前
Agent 确定性上下文设计:从 Prompt 参数注入到能力分层
java·开发语言·微服务·架构·prompt·agent context
专注仿真6 小时前
引擎扩展性与集成设计深度剖析:从 14 个扩展点到 DIS→HLA 演进之路
开发语言·算法·仿真引擎·推演引擎
码爸6 小时前
支持向量机介绍与示例
算法·机器学习·支持向量机
怕浪猫6 小时前
2028编程圈很火的10个Skills
算法·面试·github
Best-Wishes6 小时前
科来网络分析系统(技术交流版)使用说明书
开发语言·junit·php
代码不停7 小时前
自动化测试(java)
java·开发语言·selenium·自动化
别动我齐刘海8 小时前
Linux 系统调试学习1
linux·运维·服务器·c++·学习·机器学习·机器人
鬼手点金8 小时前
opencode-rules 插件
java·开发语言·前端·人工智能·chrome·git·github