图书管理系统
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | #include<map> #include<windows.h> #include<fstream> #include<iostream> using namespace std; int i=0,j=0,change; struct book{ string name; string zhu; string clas; string cbs; string money; int num; int bianhao; int jie; }; map< int ,book> a; book b[100]; void jm(){ cout<< "图书管理系统:" <<endl; cout<< "1.修改图书信息" <<endl; cout<< "2.输出可借图书信息" <<endl; cout<< "3.查询图书信息" <<endl; cout<< "4.退出" <<endl; } //void one(){ // cout<<"你要修改哪个类别(1.人文 , 2.数理)"<<endl; // cin>>change; // case 1: // // break; // case 2: // cout<<"你要修改哪个属性(1.名称,2.作者,3.类别,4.出版社,5.售价,6.数量)"<<endl; // break; //} void two(){ j=0; system ( "cls" ); for (j=0;j<i;j++){ if (a[j].jie==1){ cout<<a[j].name<< " " ; cout<<a[j].zhu<< " " ; cout<<a[j].clas<< " " ; cout<<a[j].cbs<< " " ; cout<<a[j].money<< " " ; cout<<a[j].num<< " " ; cout<<a[j].bianhao<< " " <<endl; } } system ( "pause" ); } void three(){ system ( "cls" ); while (1){ cout<< "请输入:" <<endl; cout<< "1.你要查找书的编号" <<endl; // cout<<"2.你要查找书的名称"<<endl; cout<< "2.退出" <<endl; cin>>change; if (change==2){ break ; } else { cout<< "编号:" ; cin>>change; cout<<a[change].name<< " " ; cout<<a[change].zhu<< " " ; cout<<a[change].clas<< " " ; cout<<a[change].cbs<< " " ; cout<<a[change].money<< " " ; cout<<a[change].num<< " " ; cout<<a[change].bianhao<< " " ; cout<<a[change].jie<< " " <<endl; cout<< "----------------" <<endl; } } } int main(){ string d[100]; ifstream c; c.open( "1.txt" ); while (getline(c,d[i])){ i++; } c.close(); while (j<i){ if (d[j].length()>=3){ b[j].name=d[j].substr(0,d[j].find( "|" )); d[j]=d[j].substr(d[j].find( "|" )+1); b[j].zhu=d[j].substr(0,d[j].find( "|" )); d[j]=d[j].substr(d[j].find( "|" )+1); b[j].clas=d[j].substr(0,d[j].find( "|" )); d[j]=d[j].substr(d[j].find( "|" )+1); b[j].cbs=d[j].substr(0,d[j].find( "|" )); d[j]=d[j].substr(d[j].find( "|" )+1); b[j].money=d[j].substr(0,d[j].find( "|" )); d[j]=d[j].substr(d[j].find( "|" )+1); b[j].num=stoi(d[j].substr(0,d[j].find( "|" ))); d[j]=d[j].substr(d[j].find( "|" )+1); b[j].bianhao=stoi(d[j].substr(0,d[j].find( "|" ))); d[j]=d[j].substr(d[j].find( "|" )+1); b[j].jie=stoi(d[j].substr(0,d[j].find( "|" ))); } j++; } j=0; while (j<i){ a.insert(pair< int ,book>(j,b[j])); j++; } while (1){ system ( "cls" ); jm(); cin>>change; switch (change){ case 1: // one(); break ; case 2: two(); break ; case 3: three(); break ; case 4: return 0; } } // ofstream e; // b.name="数学"; // b.zhu="哈哈"; // b.clas="人文"; // b.cbs="人民大学出版社"; // b.money="9.9"; // b.num=1; // e.open("1.txt",ios::app); // e<<b.name<<"|"<<b.zhu<<"|"<<b.clas<<"|"<<b.cbs<<"|"<<b.money<<"|"<<b.num<<endl; // e.close(); return 0; } |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】