C语言图书信息管理系统,具体操作包括图书信息的录入、添加、显示、查找、删除、排序和保存等功能。

C语言图书信息管理系统,具体操作包括图书信息的录入、添加、显示、查找、删除、排序和保存等功能。图书入库: 即添加新的图书信息记录
图书显示按图书编号顺序或按图书名称显示图书信息
可以扩充功能,如添加按图书种类显示,按作者名显示等。
图书查询: 输入图书名称或图书编号则显示相关图书的信息
可以扩充功能,如添加按图书种类查询、按作者名查询等。
图书修改: 即修改已录入的图书信息记录。
图书报度: 即删除不需要的图书信记录息。
图书信息保存: 当添加、修改、删除信息后,应该将其存入文件。
g.退出系统
系统使用说明: 执行一个具体的功能之后,程序将重斯显示功能菜单。系统的功
能并不限于上述,可以对其进行扩充完善,如在对信息进行修改和删除时,可以考
虑系统的安全性,在执行前若输入正确密码,才可进行操作。

测试数据:
图书数目>=20

#include <cstring>

#include <vector>

#include <fstream>

#include <map>

#include <iostream>

#include <algorithm>

using namespace std;

class Library{

map<string,string> book_num;

vector<string> people_num;

map<string,string>::iterator ib;

vector<string>::iterator ip;

public:

Library(){

ib=book_num.begin();

ip=people_num.begin();

}

void set_book_num(string,string);

void delete_book_num(string);

void find_book_num(string);

void change_booke_num(string,string);

void add_people_num(string);

void lend_num(string,string);

void return_num(string,string);

void file_book(vector<string>::iterator);

void file_people(vector<string>::iterator);

};

void Library::set_book_num(string A,string B){

book_num.insert(A,B);

}

void Library::add_people_num(string A){

people_num.push_back(A);

}

void Library::find_book_num(string A){

map<string,string>::iterator result =find(book_num.begin(), book_num.end(), A);

if(result==book_num.end())

cout<<"图书馆中查无此书!"<<endl;

else

cout<<"图书馆中此书信息如下:"<<endl;

cout<<result->first<<":"<<result->second<<endl;

}

void Library::delete_book_num(string A){

map<string,string>::iterator result =find(book_num.begin(), book_num.end(), A);

if(result==book_num.end())

cout<<"图书馆中查无此书!"<<endl;

else

book_num.erase(result);

cout<<"已成功删除该书在图书馆中的记录"<<endl;

}

void Library::change_booke_num(string A,string B){

map<string,string>::iterator result =find(book_num.begin(), book_num.end(), A);

if(result==book_num.end())

cout<<"图书馆中查无此书!"<<endl;

else

result->second=B;

}

void Library::file_people(vector<string>::iterator ifp){

ofstream file_p;

file_p.open("/Users/apple/Documents/Library_p.txt",ios::out);

if(!file_p.is_open())

{

cerr<<"open file_people fail"<<endl;

exit(-1);

}

file_p<<*ifp<<endl;

file_p.close();

}

void Library::file_book(vector<string>::iterator ibp){

ofstream file_b;

file_b.open("/Users/apple/Documents/Library_b.txt",ios::out);

if(!file_b.is_open())

{

cerr<<"open file_people fail"<<endl;

exit(-1);

}

file_b<<*ibp<<endl;

file_b.close();

}


温馨提示:答案为网友推荐,仅供参考
相似回答