图书管理系统,数组存储和链表存储
#include <bits/stdc++.h> using namespace std; fstream in,out; int n=0; string temp[4]; struct book { string isbn; string name; double price; }b[205]; inline bool Check()//时间O(n),空间O(1)。检查是否读入图书信息 { if(n==0) { cout<<"请先选择1读取图书信息\n"; return false; } return true; } inline void Input()//时间O(n),空间O(1)。读入图书信息 { in.open("book.txt",ios::in); if(!in) { cout<<"未找到book.txt\n"; return; } n=1; for(int i=1;i<=4;++i)in>>temp[i]; while(!in.eof()) { in>>b[n].isbn>>b[n].name>>b[n].price; n++; } in.close(); } inline void Output()//时间O(n),空间O(1)。输出图书信息 { if(Check()) { cout<<temp[1]<<"\n"<<left<<setw(15)<<temp[2]<