1 #include <iostream>
2 #include <fstream>
3 #include <map>
4 using namespace std;
5 struct book{
6 string name;
7 float moeny;
8 string cbs;
9 };
10 void _main(){
11 cout<<"Hello,welcome to the library!"<<endl;
12 cout<<" What do I do for you?"<<endl;
13 cout<<" 1.借阅"<<endl;
14 cout<<" 2.增书"<<endl;
15 cout<<" 3.查书"<<endl;
16 cout<<" 4.还书"<<endl;
17 cout<<" 5.关闭"<<endl;
18 }
19 int main(int argc, char** argv) {
20 string data,k;
21 map<string,book> my_map;
22 book sx;
23 ifstream file;
24 file.open("1.txt");
25 //
26 book c;
27 while(getline(file,data)){
28 if(data.length()>4){
29 c.name = data.substr(0,data.find("|"));
30 data = data.substr(data.find("|")+1);
31 c.moeny=stof(data.substr(0,data.find("|")));
32 data = data.substr(data.find("|")+1);
33 c.cbs = data.substr(0,data.find("|"));
34 data = data.substr(data.find("|")+1);
35 k = data.substr(0,data.find("|"));
36 my_map.insert(pair<string,book>(k,c));
37 }
38 if(file.eof()){
39 break;
40 }
41 }
42 file.close();
43 int i;
44 while(1){
45 system("cls");
46 _main();
47 cin>>i;
48 switch(i){
49 case 1:{
50
51 break;
52 }
53 case 5:{
54 return 0;
55 break;
56 }
57 system("pause");
58 }
59 }
60 return 0;
61 }