C++图书馆管理系统(简单版)

这篇具有很好参考价值的文章主要介绍了C++图书馆管理系统(简单版)。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

1、 总体功能分析

实用的图书馆管理系统应该至少包括一下功能:

1、上传:新进图书以及基本信息的输入

2、删除:旧图书以及基本信息的删除

3、显示:显示图书馆已有的所有图书

4、查找:查询要借阅的图书信息

5、借阅:实现用户办理借阅手续

6、归还:实现用户办理归还手续

系统以菜单方式工作使界面友好,易于操作。

2、建立相关属性

由于系统设计的是一些图书和读者的信息存储,因此,需要定义一个数据结构来存储相关信息。

首先需要建立一个图书类、图书数据库类、读者类以及读者数据库类,并定义图书和读者的各种属性。

#include "iostream"
#include "string"
#include "conio.h"
using namespace std;

struct Date{//日期结构
    int m_nYear;//年
    int m_nMonth;//月
    int m_nDay;//日
};

struct Reader{//读者结构
    string name;//读者姓名
    Date bro;//借出时间
    Date back;//归还时间
};

struct Book{//图书结构
    int m_nBook_Number;//图书编号
    string m_strTitle;//书名
    string m_strWroter;//作者
    int m_nMoreNum;//当前在图书馆数量
    int m_nTotalHoldNum;//图书馆共计数量
    string m_sttrComment;//图书介绍
    Reader reader[20];
};

struct Info{//借书信息结构
    Info *m_pParentPoint;//前驱节点
    Book *m_oBookInfo;//对应图书信息
    Info *m_pNextPoint;//后继节点

};

3、图书馆菜单

程序开始运行,将显示选择菜单,供用户选择需要的功能,用户根据需要,输入不同的数字来选择相应功能。

int  Select_Menu(){
    //图书管理系统主界面
    cout << "--------------------------------------------------" << endl << endl;
    cout << "              图  书  馆  管  理  系  统             " << endl;
    cout << "                     主  菜  单                     " << endl << endl;
    cout << "                    1.上传图书" << endl;
    cout << "                    2.下架图书" << endl;
    cout << "                    3.显示图书" << endl;
    cout << "                    4.借阅图书" << endl;
    cout << "                    5.归还图书" << endl;
    cout << "                    6.退出系统" << endl << endl;
    cout << "               请选择菜单项:(1-6)" << endl;
    cout << "--------------------------------------------------" << endl;
    int id = 0;//编号
    cout << "请输入您的选择:";
    cin >> id;
    return id;
}

4、图书上传

将图书信息添加到图书馆中

Book *InputNode(){
    //上传图书
    Book *p = new Book;//动态分配一片大小为sizeof(Book)字节的空间,并将该内存空间的起始位置赋值给p
    system("cls");//清屏
    fflush(stdin);//清楚以前的输入
    cout << "请输入图书编号:"; cin >> p->m_nBook_Number;
    cout << "请输入图书:"; cin >> p->m_strTitle;
    cout << "请输入作者:"; cin >> p->m_strWroter;
    cout << "请输入当前在图书馆数量:"; cin >> p->m_nMoreNum;
    cout << "请输入图书馆共计数量:"; cin >> p->m_nTotalHoldNum;
    cout << "请输入图书介绍:"; cin >> p->m_sttrComment;
    for(int i = 0; i < 20; i++){//初始化书本结构成员中相关读者指针内容为空
        (p->reader[i]).name = '\0';
    }
    return p;//返回成功读入的书本信息
}

Info *Insert_BookInfo(Info *bth){
    //上传图书
    int flag, k, x;
    cout << "请输入您想上传的图书编号:";//按照书本编号进行查找
    cin >> x;
    Info *p = Sreach(bth, x, &k, &flag);
    if(flag == 1){//找到直接对已有的数量进行修改
        cout << "当前图书馆内拥有这本书" << p->m_oBookInfo->m_nMoreNum << "本,您想在增加一本" << p->m_oBookInfo->m_strTitle << "书?(Y/N)" << endl;
        char ch;
        cin >> ch;
        if(ch == 'Y' || ch == 'y'){
            p->m_oBookInfo->m_nMoreNum++;
            p->m_oBookInfo->m_nTotalHoldNum++;
            cout << "增加后图书馆内拥有这本书" << p->m_oBookInfo->m_nMoreNum << "本,一共拥有" << p->m_oBookInfo->m_nTotalHoldNum << "本" << endl;
        }
        return bth;
    }
    //图书管内未找到这本图书编号
    Book * r = InputNode();
    if(bth == NULL){//当bth指针为空时,需要对其进行单独处理,链表表头内存的分配
        bth = new Info;
        bth->m_pParentPoint = NULL;
        bth->m_oBookInfo = r;
        bth->m_pNextPoint = NULL;
    }
    else {
        //说明存在头指针
        p = bth;
        while (p->m_pNextPoint != NULL)
            p = p->m_pNextPoint;
        Info *q = new Info;
        q->m_oBookInfo = r;
        q->m_pNextPoint = NULL;
        q->m_pParentPoint = p;
        p->m_pNextPoint = q;
    }
    return bth;
}

5、 删除图书

将图书信息从图书馆中删除

Info *Delete_BookInfo(Info * bth){
    //删除图书
    int flag, k, x;
    cout << "请输入您想删除的图书编号:";//按照书本编号进行查找
    cin >> x;
    Info *p = Sreach(bth, x, &k, &flag);
    if(flag == 0){//为查找图书编号
        cout << "图书馆内并没有这本书!!!" << endl;
        return bth;
    }
    else{
        if(p == NULL){//确保当前操作是有效的,防止出现非法操作
            cout << "查找错误" << endl;
            return bth;
        }
        else {
            cout << "你想删除的图书信息如下:" << endl;
            cout << "图书编号:" << p->m_oBookInfo->m_nBook_Number << endl;
            cout << "书名:" << p->m_oBookInfo->m_strTitle << endl;
            cout << "作者:" << p->m_oBookInfo->m_strWroter << endl;
            cout << "当前在馆图书数量:" << p->m_oBookInfo->m_nMoreNum << endl;
            cout << "图书共计数量:" << p->m_oBookInfo->m_nTotalHoldNum << endl;
            cout << "这本图书简介:" << p->m_oBookInfo->m_sttrComment << endl;
            cout << "您确定删除吗?(Y/N)" << endl;
            char ch;
            cin >> ch;
            if(ch == 'Y' || 'y'){
                if(p->m_pNextPoint != NULL && p->m_pParentPoint != NULL){//夹在链表中间的节点
                    Info *Left = p->m_pParentPoint;//将要删除节点的前驱节点指向赋值给前驱结点指针变量
                    Info *Right = p->m_pNextPoint;//将要删除节点的后继结点指向赋值给后继结点指针变量
                    Left->m_pNextPoint = Right;//将后继结点指针指向的地址作为前驱结点的后继域
                    Right->m_pParentPoint = Left;//将前驱结点指针指向的地址作为后继结点的前驱域
                    //释放空间
                    p->m_pNextPoint = NULL;
                    p->m_pParentPoint = NULL;
                    delete p->m_oBookInfo;
                    p->m_oBookInfo = NULL;
                    delete p;
                    p = NULL;
                    return bth;
                }
                else if(p->m_pParentPoint == NULL){//首结点的前驱为空,处理首结点删除操作
                    if(p->m_pNextPoint == NULL){//说明只有一个结点
                        delete p->m_oBookInfo;
                        p->m_oBookInfo = NULL;
                        delete p;
                        p = NULL;
                        return bth;
                    }
                    bth = p->m_pNextPoint;
                    bth->m_pParentPoint = NULL;

                    p->m_pNextPoint = NULL;
                    p->m_pParentPoint = NULL;
                    delete p->m_oBookInfo;
                    p->m_oBookInfo = NULL;
                    delete p;
                    p = NULL;
                    return bth;
                }
                else if(p->m_pNextPoint == NULL){
                    Info *Left = p->m_pParentPoint;
                    Left->m_pNextPoint = NULL;

                    p->m_pNextPoint = NULL;
                    p->m_pParentPoint = NULL;
                    delete p->m_oBookInfo;
                    p->m_oBookInfo = NULL;
                    delete p;
                    p = NULL;
                    return bth;
                }
            }
        }
    }
}

6、 查找图书

根据输入的图书编号,是心啊图书的查找。

Info *Sreach(Info *bth, int x, int *k, int *flag){
    //搜索图书
    Info *p = bth;
    *flag = 0;
    while(p){
        if(p->m_oBookInfo->m_nBook_Number == x){//寻到相同的图书编号
            *flag = 1;
            return p;
        }
        else {
            *flag = 0;
        }
        if(p->m_pNextPoint != NULL) {
            p = p->m_pNextPoint;
        }
        else{
            break;
        }
    }
    return bth;
}

7、显示图书信息

显示图书馆中所有的图书信息。

void Output_BookInfo(Info * bth){
    //输出图书信息
    system("cls");
    Info *p = bth;
    while (p){
        cout << "图书编号:" << p->m_oBookInfo->m_nBook_Number;
        cout << "书名:" << p->m_oBookInfo->m_strTitle;
        cout << "作者:" << p->m_oBookInfo->m_strWroter;
        cout << "当前在馆图书数量:" << p->m_oBookInfo->m_nMoreNum;
        cout << "图书共计数量:" << p->m_oBookInfo->m_nTotalHoldNum;
        cout << "这本图书简介:" << p->m_oBookInfo->m_sttrComment << endl;
        p = p->m_pNextPoint;
    }
}

8、图书借阅

根据输入的相关信息,实现借阅

void Borrow_TheBook(Info *bth){
    //图书借出
    system("cls");
    int flag, k, x, i = 0;
    cout << "请输入您想借阅的图书编号:";//按照书本编号进行查找
    cin >> x;
    Info *p = Sreach(bth, x, &k, &flag);
    if(flag == 1){
        Book *r = p->m_oBookInfo;
        cout << "你想借阅的图书信息如下:" << endl;
        cout << "书名:" << p->m_oBookInfo->m_strTitle << endl;
        cout << "作者:" << p->m_oBookInfo->m_strWroter << endl;
        cout << "当前在馆图书数量:" << p->m_oBookInfo->m_nMoreNum << endl;
        cout << "图书共计数量:" << p->m_oBookInfo->m_nTotalHoldNum << endl;
        cout << "这本图书简介:" << p->m_oBookInfo->m_sttrComment << endl;
        cout << "您确定借阅吗?(Y/N)" << endl;
        char ch;
        cin >> ch;
        if(ch == 'Y' || ch == 'y'){
            if(r->m_nMoreNum == 0) cout << "对不起,本书 已经全部借出···" << endl;
            else{
                system("cls");
                for(i = 0; i < 20; i++)
                    if((r->reader[i]).name[0] == '\0') break;
                cout << "请输入借阅者的姓名:";cin >> (r->reader[i]).name;
                cout << "请输入借出日期:" << endl;
                cout << "请输入借出年份:";cin >> (r->reader[i]).bro.m_nYear;
                cout << "请输入借出月份:";cin >> (r->reader[i]).bro.m_nMonth;
                cout << "请输入借出日:";cin >> (r->reader[i]).bro.m_nDay;
                cout << "请输入归还日期:" << endl;
                cout << "请输入归还年份:";cin >> (r->reader[i]).back.m_nYear;
                cout << "请输入归还月份:";cin >> (r->reader[i]).back.m_nMonth;
                cout << "请输入归还日:";cin >> (r->reader[i]).back.m_nDay;
                r->m_nMoreNum--;
                cout << endl << "成功接到这本书" << endl;
            }
        }
    }
}

9、图书归还

根据输入的图书编号归还图书。文章来源地址https://www.toymoban.com/news/detail-492713.html

void TurnBack_TheBook(Info *bth){
    //图书归还
    system("cls");
    int flag, k, x, i = 0, j = 0;
    cout << "请输入您想借阅的图书编号:";//按照书本编号进行查找
    cin >> x;
    Info *p = Sreach(bth, x, &k, &flag);
    if(flag == 1){
        Book *r = p->m_oBookInfo;
        cout << "你想归还的图书信息如下:" << endl;
        cout << "书名:" << p->m_oBookInfo->m_strTitle << endl;
        cout << "作者:" << p->m_oBookInfo->m_strWroter << endl;
        cout << "当前在馆图书数量:" << p->m_oBookInfo->m_nMoreNum << endl;
        cout << "图书共计数量:" << p->m_oBookInfo->m_nTotalHoldNum << endl;
        cout << "这本图书简介:" << p->m_oBookInfo->m_sttrComment << endl;
        cout << "您确定归还吗?(Y/N)" << endl;
        char ch;
        cin >> ch;
        if(ch == 'Y' || ch == 'y'){
            system("cls");
            cout << "请输入借阅者的姓名:";
            string nm;
            cin >> nm;
            for(i = 0; i < 20; i++)
                if((r->reader[i]).name == nm) {
                    j = 1;
                    break;
                }
            if(j == 0) {
                cout << "你未借阅过这本书" << endl;
                return;
            }
            (r->reader[i]).name[0] = '\0';
            r->m_nMoreNum++;
            cout << "书名:" << p->m_oBookInfo->m_strTitle << endl;
            cout << "作者:" << p->m_oBookInfo->m_strWroter << endl;
            cout << "当前在馆图书数量:" << p->m_oBookInfo->m_nMoreNum << endl;
            cout << "图书共计数量:" << p->m_oBookInfo->m_nTotalHoldNum << endl;
            cout << "这本图书简介:" << p->m_oBookInfo->m_sttrComment << endl;
        }
    }
    else cout << "您不能归还不存在的图书" << endl;
}

10、完整代码

#include "iostream"
#include "string"
#include "conio.h"
using namespace std;

struct Date{//日期结构
    int m_nYear;//年
    int m_nMonth;//月
    int m_nDay;//日
};

struct Reader{//读者结构
    string name;//读者姓名
    Date bro;//借出时间
    Date back;//归还时间
};

struct Book{//图书结构
    int m_nBook_Number;//图书编号
    string m_strTitle;//书名
    string m_strWroter;//作者
    int m_nMoreNum;//当前在图书馆数量
    int m_nTotalHoldNum;//图书馆共计数量
    string m_sttrComment;//图书介绍
    Reader reader[20];
};

struct Info{//借书信息结构
    Info *m_pParentPoint;//前驱节点
    Book *m_oBookInfo;//对应图书信息
    Info *m_pNextPoint;//后继节点

};

Book *InputNode(){
    //上传图书
    Book *p = new Book;//动态分配一片大小为sizeof(Book)字节的空间,并将该内存空间的起始位置赋值给p
    system("cls");//清屏
    fflush(stdin);//清楚以前的输入
    cout << "请输入图书编号:"; cin >> p->m_nBook_Number;
    cout << "请输入图书:"; cin >> p->m_strTitle;
    cout << "请输入作者:"; cin >> p->m_strWroter;
    cout << "请输入当前在图书馆数量:"; cin >> p->m_nMoreNum;
    cout << "请输入图书馆共计数量:"; cin >> p->m_nTotalHoldNum;
    cout << "请输入图书介绍:"; cin >> p->m_sttrComment;
    for(int i = 0; i < 20; i++){//初始化书本结构成员中相关读者指针内容为空
        (p->reader[i]).name = '\0';
    }
    return p;//返回成功读入的书本信息
}

Info *Sreach(Info *bth, int x, int *k, int *flag){
    //搜索图书
    Info *p = bth;
    *flag = 0;
    while(p){
        if(p->m_oBookInfo->m_nBook_Number == x){//寻到相同的图书编号
            *flag = 1;
            return p;
        }
        else {
            *flag = 0;
        }
        if(p->m_pNextPoint != NULL) {
            p = p->m_pNextPoint;
        }
        else{
            break;
        }
    }
    return bth;
}

Info *Insert_BookInfo(Info *bth){
    //上传图书
    int flag, k, x;
    cout << "请输入您想上传的图书编号:";//按照书本编号进行查找
    cin >> x;
    Info *p = Sreach(bth, x, &k, &flag);
    if(flag == 1){//找到直接对已有的数量进行修改
        cout << "当前图书馆内拥有这本书" << p->m_oBookInfo->m_nMoreNum << "本,您想在增加一本" << p->m_oBookInfo->m_strTitle << "书?(Y/N)" << endl;
        char ch;
        cin >> ch;
        if(ch == 'Y' || ch == 'y'){
            p->m_oBookInfo->m_nMoreNum++;
            p->m_oBookInfo->m_nTotalHoldNum++;
            cout << "增加后图书馆内拥有这本书" << p->m_oBookInfo->m_nMoreNum << "本,一共拥有" << p->m_oBookInfo->m_nTotalHoldNum << "本" << endl;
        }
        return bth;
    }
    //图书管内未找到这本图书编号
    Book * r = InputNode();
    if(bth == NULL){//当bth指针为空时,需要对其进行单独处理,链表表头内存的分配
        bth = new Info;
        bth->m_pParentPoint = NULL;
        bth->m_oBookInfo = r;
        bth->m_pNextPoint = NULL;
    }
    else {
        //说明存在头指针
        p = bth;
        while (p->m_pNextPoint != NULL)
            p = p->m_pNextPoint;
        Info *q = new Info;
        q->m_oBookInfo = r;
        q->m_pNextPoint = NULL;
        q->m_pParentPoint = p;
        p->m_pNextPoint = q;
    }
    return bth;
}

Info *Delete_BookInfo(Info * bth){
    //删除图书
    int flag, k, x;
    cout << "请输入您想删除的图书编号:";//按照书本编号进行查找
    cin >> x;
    Info *p = Sreach(bth, x, &k, &flag);
    if(flag == 0){//为查找图书编号
        cout << "图书馆内并没有这本书!!!" << endl;
        return bth;
    }
    else{
        if(p == NULL){//确保当前操作是有效的,防止出现非法操作
            cout << "查找错误" << endl;
            return bth;
        }
        else {
            cout << "你想删除的图书信息如下:" << endl;
            cout << "图书编号:" << p->m_oBookInfo->m_nBook_Number << endl;
            cout << "书名:" << p->m_oBookInfo->m_strTitle << endl;
            cout << "作者:" << p->m_oBookInfo->m_strWroter << endl;
            cout << "当前在馆图书数量:" << p->m_oBookInfo->m_nMoreNum << endl;
            cout << "图书共计数量:" << p->m_oBookInfo->m_nTotalHoldNum << endl;
            cout << "这本图书简介:" << p->m_oBookInfo->m_sttrComment << endl;
            cout << "您确定删除吗?(Y/N)" << endl;
            char ch;
            cin >> ch;
            if(ch == 'Y' || 'y'){
                if(p->m_pNextPoint != NULL && p->m_pParentPoint != NULL){//夹在链表中间的节点
                    Info *Left = p->m_pParentPoint;//将要删除节点的前驱节点指向赋值给前驱结点指针变量
                    Info *Right = p->m_pNextPoint;//将要删除节点的后继结点指向赋值给后继结点指针变量
                    Left->m_pNextPoint = Right;//将后继结点指针指向的地址作为前驱结点的后继域
                    Right->m_pParentPoint = Left;//将前驱结点指针指向的地址作为后继结点的前驱域
                    //释放空间
                    p->m_pNextPoint = NULL;
                    p->m_pParentPoint = NULL;
                    delete p->m_oBookInfo;
                    p->m_oBookInfo = NULL;
                    delete p;
                    p = NULL;
                    return bth;
                }
                else if(p->m_pParentPoint == NULL){//首结点的前驱为空,处理首结点删除操作
                    if(p->m_pNextPoint == NULL){//说明只有一个结点
                        delete p->m_oBookInfo;
                        p->m_oBookInfo = NULL;
                        delete p;
                        p = NULL;
                        return bth;
                    }
                    bth = p->m_pNextPoint;
                    bth->m_pParentPoint = NULL;

                    p->m_pNextPoint = NULL;
                    p->m_pParentPoint = NULL;
                    delete p->m_oBookInfo;
                    p->m_oBookInfo = NULL;
                    delete p;
                    p = NULL;
                    return bth;
                }
                else if(p->m_pNextPoint == NULL){
                    Info *Left = p->m_pParentPoint;
                    Left->m_pNextPoint = NULL;

                    p->m_pNextPoint = NULL;
                    p->m_pParentPoint = NULL;
                    delete p->m_oBookInfo;
                    p->m_oBookInfo = NULL;
                    delete p;
                    p = NULL;
                    return bth;
                }
            }
        }
    }
}

void Output_BookInfo(Info * bth){
    //输出图书信息
    system("cls");
    Info *p = bth;
    while (p){
        cout << "图书编号:" << p->m_oBookInfo->m_nBook_Number;
        cout << "书名:" << p->m_oBookInfo->m_strTitle;
        cout << "作者:" << p->m_oBookInfo->m_strWroter;
        cout << "当前在馆图书数量:" << p->m_oBookInfo->m_nMoreNum;
        cout << "图书共计数量:" << p->m_oBookInfo->m_nTotalHoldNum;
        cout << "这本图书简介:" << p->m_oBookInfo->m_sttrComment << endl;
        p = p->m_pNextPoint;
    }
}

void Borrow_TheBook(Info *bth){
    //图书借出
    system("cls");
    int flag, k, x, i = 0;
    cout << "请输入您想借阅的图书编号:";//按照书本编号进行查找
    cin >> x;
    Info *p = Sreach(bth, x, &k, &flag);
    if(flag == 1){
        Book *r = p->m_oBookInfo;
        cout << "你想借阅的图书信息如下:" << endl;
        cout << "书名:" << p->m_oBookInfo->m_strTitle << endl;
        cout << "作者:" << p->m_oBookInfo->m_strWroter << endl;
        cout << "当前在馆图书数量:" << p->m_oBookInfo->m_nMoreNum << endl;
        cout << "图书共计数量:" << p->m_oBookInfo->m_nTotalHoldNum << endl;
        cout << "这本图书简介:" << p->m_oBookInfo->m_sttrComment << endl;
        cout << "您确定借阅吗?(Y/N)" << endl;
        char ch;
        cin >> ch;
        if(ch == 'Y' || ch == 'y'){
            if(r->m_nMoreNum == 0) cout << "对不起,本书 已经全部借出···" << endl;
            else{
                system("cls");
                for(i = 0; i < 20; i++)
                    if((r->reader[i]).name[0] == '\0') break;
                cout << "请输入借阅者的姓名:";cin >> (r->reader[i]).name;
                cout << "请输入借出日期:" << endl;
                cout << "请输入借出年份:";cin >> (r->reader[i]).bro.m_nYear;
                cout << "请输入借出月份:";cin >> (r->reader[i]).bro.m_nMonth;
                cout << "请输入借出日:";cin >> (r->reader[i]).bro.m_nDay;
                cout << "请输入归还日期:" << endl;
                cout << "请输入归还年份:";cin >> (r->reader[i]).back.m_nYear;
                cout << "请输入归还月份:";cin >> (r->reader[i]).back.m_nMonth;
                cout << "请输入归还日:";cin >> (r->reader[i]).back.m_nDay;
                r->m_nMoreNum--;
                cout << endl << "成功接到这本书" << endl;
            }
        }
    }
}

void TurnBack_TheBook(Info *bth){
    //图书归还
    system("cls");
    int flag, k, x, i = 0, j = 0;
    cout << "请输入您想借阅的图书编号:";//按照书本编号进行查找
    cin >> x;
    Info *p = Sreach(bth, x, &k, &flag);
    if(flag == 1){
        Book *r = p->m_oBookInfo;
        cout << "你想归还的图书信息如下:" << endl;
        cout << "书名:" << p->m_oBookInfo->m_strTitle << endl;
        cout << "作者:" << p->m_oBookInfo->m_strWroter << endl;
        cout << "当前在馆图书数量:" << p->m_oBookInfo->m_nMoreNum << endl;
        cout << "图书共计数量:" << p->m_oBookInfo->m_nTotalHoldNum << endl;
        cout << "这本图书简介:" << p->m_oBookInfo->m_sttrComment << endl;
        cout << "您确定归还吗?(Y/N)" << endl;
        char ch;
        cin >> ch;
        if(ch == 'Y' || ch == 'y'){
            system("cls");
            cout << "请输入借阅者的姓名:";
            string nm;
            cin >> nm;
            for(i = 0; i < 20; i++)
                if((r->reader[i]).name == nm) {
                    j = 1;
                    break;
                }
            if(j == 0) {
                cout << "你未借阅过这本书" << endl;
                return;
            }
            (r->reader[i]).name[0] = '\0';
            r->m_nMoreNum++;
            cout << "书名:" << p->m_oBookInfo->m_strTitle << endl;
            cout << "作者:" << p->m_oBookInfo->m_strWroter << endl;
            cout << "当前在馆图书数量:" << p->m_oBookInfo->m_nMoreNum << endl;
            cout << "图书共计数量:" << p->m_oBookInfo->m_nTotalHoldNum << endl;
            cout << "这本图书简介:" << p->m_oBookInfo->m_sttrComment << endl;
        }
    }
    else cout << "您不能归还不存在的图书" << endl;
}

int  Select_Menu(){
    //图书管理系统主界面
    cout << "--------------------------------------------------" << endl << endl;
    cout << "              图  书  馆  管  理  系  统             " << endl;
    cout << "                     主  菜  单                     " << endl << endl;
    cout << "                    1.上传图书" << endl;
    cout << "                    2.下架图书" << endl;
    cout << "                    3.显示图书" << endl;
    cout << "                    4.借阅图书" << endl;
    cout << "                    5.归还图书" << endl;
    cout << "                    6.退出系统" << endl << endl;
    cout << "               请选择菜单项:(1-6)" << endl;
    cout << "--------------------------------------------------" << endl;
    int id = 0;//编号
    cout << "请输入您的选择:";
    cin >> id;
    return id;
}

int main(){
    Info *bth = NULL;
    while(true){
        int id = Select_Menu();
        switch (id) {
            case 1:
                bth = Insert_BookInfo(bth);
                break;
            case 2:
                bth = Delete_BookInfo(bth);
                break;
            case 3:
                Output_BookInfo(bth);
                break;
            case 4:
                Borrow_TheBook(bth);
                break;
            case 5:
                TurnBack_TheBook(bth);
                break;
            case 6:
                system("cls");
                cout << "您确定要退出系统(Y/N)";
                char t;
                cin >> t;
                if(t == 'y' || t == 'Y') exit(0);
                break;
        }
        cout << "按任意键返回主菜单.......";
    }
}

到了这里,关于C++图书馆管理系统(简单版)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Python+Django+MySQL的图书馆管理系统【附源码,运行简单】

    自己做的项目,禁止转载,基于Python+Django+MySQL的图书馆管理系统,带用户登录、注册,基本的出版社、作者、图书信息的增删改查功能,还有分页功能,用Pycharm导入,安装依赖包,配置好数据库就可以正常运行了,里面的代码都含有注释,结构简单,清晰易懂,看一下就会

    2024年01月17日
    浏览(41)
  • 实战 图书馆系统管理案例

    config :敏感的配置一般都是在配置中心配置,比如consul或者阿波罗上面 controller :写一些handler的,拿到参数要去调用service层的逻辑。( 只负责接受参数,怎么绑定参数,要去调用哪个service的,handler的一个入口 ) service: service层才是正真的业务处理层 。调用dao层的增删改

    2024年02月11日
    浏览(37)
  • Java 实现图书馆管理系统

    目录 一:创建对象 1.学生类对象Student : 2.图书类对象book : 3.管理员类对象OP: 二.创建主要交互界面MainMenu,并实现主界面功能 1.创建交互界面: 2.实现主界面功能: 三:创建OP管理界面: 1.创建主要交互界面及实现\\\"管理学生\\\"功能OPmenu: (1).交互界面: (2):实现\\\"管理学生\\\"功能: 2.实现\\\"管理

    2024年02月12日
    浏览(32)
  • JavaWeb期末项目 图书馆管理系统

    1 项目基本信息 1.1 项目名称 图书馆管理系统 1.2 开发运行环境 Window 10 64位 JDK 1.8.0 Eclipse 4.8版本 MySql 5.5 Tomcat 9.0 2 项目需求分析 2.1 学生登录部分 (1)学生注册:在进入图书馆前必须要登录,如果没有学号则要注册,注册时系统会将用户填写的学号与数据库里面的数据对比,

    2024年02月10日
    浏览(35)
  • java项目-图书馆管理系统源码

    作者主页:夜未央5788  简介:Java领域优质创作者、Java项目、学习资料、技术互助 文末获取源码   项目介绍 本毕业设计运用了使用技术:spring mvc+spring+hibernate,数据库使用了当前较为流行的Mysql5.7。根据本校图书馆的工作流程与实际的需求和特色,本系统需满足以下几个方

    2024年02月08日
    浏览(36)
  • 基于JavaWeb的图书馆管理系统

    🍅 作者主页:

    2024年02月05日
    浏览(34)
  • c语言课程设计(图书馆管理系统)

    大一c语言课程设计:图书馆管理系统。 图书管理系统,功能齐全拿来就能用 1.主界面   代码段  2.图书录入界面 运用文件录入多次使用   代码段  3.图书查询界面 根据输入书的数据与文件中数据进行比对 ,查找后输出。 代码段 4.图书修改 输入修改图书数据并在文件中查找

    2024年02月11日
    浏览(28)
  • 基于Python的图书馆管理系统的开发

    开发工具: python3.10 数据库: Python内置的SQLite3数据库,SQLite是一种嵌入式数据库,体积很小,它的数据库就是一个文件。本文 建立了Library数据库,存储系统内的管理员、图书、读者、借阅相关信息。         传统人工方式管理文件档案存在着许多缺点,如:效率低、保

    2024年02月04日
    浏览(43)
  • Java语言------图书馆管理系统(入门简略版)

    目录 一.图书管理系统分析 1.1系统设计要求  1.2设计思路 二.操作代码的实现  2.1书架书籍代码实现 2.2用户操作代码实现 2.2.1增加书籍 2.2.2移除书籍 2.2.3查询书籍 2.2.4展示书架书籍信息 2.2.5借阅书籍代码 2.2.6归还图书代码 2.2.7退出系统 3.用户登录操作  四.主函数的调用 总结

    2023年04月13日
    浏览(37)
  • 基于JAVA图书馆管理系统设计与实现

    【后台管理员功能】 广告管理:设置小程序首页轮播图广告和链接 留言列表:所有用户留言信息列表,支持删除 会员列表:查看所有注册会员信息,支持删除 资讯分类:录入、修改、查看、删除资讯分类 录入资讯:录入资讯标题、内容等信息 管理资讯:查看已录入资讯列

    2024年02月13日
    浏览(39)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包