欢迎来到天天文库
浏览记录
ID:53685115
大小:40.50 KB
页数:16页
时间:2020-04-05
《图书管理系统C++代码.doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、#include#include#include#includeusingnamespacestd;constintReader=100;constintMaxb=100;constintBor=5;classStudent{private:inttag;intnumber;charname[10];intborbook[Bor];public:Student(){}char*getname(){returnname;}intgettag(){returnt
2、ag;}intgetnumber(){returnnumber;}voidsetname(char*na){strcpy(name,na);}voiddelbook(){tag=1;}voidaddStudent(intn,char*na){tag=0;number=n;strcpy(name,na);for(inti=0;i3、i]=bookid;return;}}}intretbook(intbookid)//还书操作{for(inti=0;i4、";cout<<"]"<5、dl;}};classRData{private:inttop;//读者记录指针Studentread[Reader];public:RData()//构造函数,将Student.txt读到read[]中{Students;top=-1;fstreamfile("Student.txt",ios::in);//打开一个输入文件while(1){file.read((char*)&s,sizeof(s));if(!file)break;top++;read[top]=s;}file.close();}voidclear(){top6、=-1;}intaddStudent(intn,char*na)//查找是否存在{Student*p=equal(n);if(p==NULL){top++;read[top].addStudent(n,na);return1;}return0;}Student*equal(intStudentid)//按编号查找{for(inti=0;i<=top;i++)if(read[i].getnumber()==Studentid&&read[i].gettag()==0){return&read[i];}returnNULL;}voi7、doutput(){for(inti=0;i<=top;i++)read[i].output();}voidStudentdata();//读者库维护~RData()//析构函数,将read[]写到Student.txt文件中{fstreamfile("Student.txt",ios::out);for(inti=0;i<=top;i++)if(read[i].gettag()==0)file.write((char*)&read[i],sizeof(read[i]));file.close();}};voidRData::S8、tudentdata(){charchoice;charrname[20];intStudentid;Student*r;while(choice!='0'){cout<<"┏━━━━━━━━━━━━━┓";cout<<"┃读者维护┃";cout<<"┃━━━━━━━━━━━━━┃";cout<<"┃1.新增┃";cout<<"┃━━━━━━━━━━━━━┃";cout<<"┃2.更改┃";cout<<"┃━━━━━━━━━━━━━┃";cout<<"┃3.删除┃";cout<<"┃━━━━━━━9、━━━━━━┃";cout<<"┃4.查找┃";cout<<"┃━━━━━━━━━━━━━┃";cout<<"┃5.显示┃";cout<<"┃━━━━━━━━━━━━━┃";cout<<"┃6.全删┃";cout<<"┃━━━━━━━━━
3、i]=bookid;return;}}}intretbook(intbookid)//还书操作{for(inti=0;i4、";cout<<"]"<5、dl;}};classRData{private:inttop;//读者记录指针Studentread[Reader];public:RData()//构造函数,将Student.txt读到read[]中{Students;top=-1;fstreamfile("Student.txt",ios::in);//打开一个输入文件while(1){file.read((char*)&s,sizeof(s));if(!file)break;top++;read[top]=s;}file.close();}voidclear(){top6、=-1;}intaddStudent(intn,char*na)//查找是否存在{Student*p=equal(n);if(p==NULL){top++;read[top].addStudent(n,na);return1;}return0;}Student*equal(intStudentid)//按编号查找{for(inti=0;i<=top;i++)if(read[i].getnumber()==Studentid&&read[i].gettag()==0){return&read[i];}returnNULL;}voi7、doutput(){for(inti=0;i<=top;i++)read[i].output();}voidStudentdata();//读者库维护~RData()//析构函数,将read[]写到Student.txt文件中{fstreamfile("Student.txt",ios::out);for(inti=0;i<=top;i++)if(read[i].gettag()==0)file.write((char*)&read[i],sizeof(read[i]));file.close();}};voidRData::S8、tudentdata(){charchoice;charrname[20];intStudentid;Student*r;while(choice!='0'){cout<<"┏━━━━━━━━━━━━━┓";cout<<"┃读者维护┃";cout<<"┃━━━━━━━━━━━━━┃";cout<<"┃1.新增┃";cout<<"┃━━━━━━━━━━━━━┃";cout<<"┃2.更改┃";cout<<"┃━━━━━━━━━━━━━┃";cout<<"┃3.删除┃";cout<<"┃━━━━━━━9、━━━━━━┃";cout<<"┃4.查找┃";cout<<"┃━━━━━━━━━━━━━┃";cout<<"┃5.显示┃";cout<<"┃━━━━━━━━━━━━━┃";cout<<"┃6.全删┃";cout<<"┃━━━━━━━━━
4、";cout<<"]"<5、dl;}};classRData{private:inttop;//读者记录指针Studentread[Reader];public:RData()//构造函数,将Student.txt读到read[]中{Students;top=-1;fstreamfile("Student.txt",ios::in);//打开一个输入文件while(1){file.read((char*)&s,sizeof(s));if(!file)break;top++;read[top]=s;}file.close();}voidclear(){top6、=-1;}intaddStudent(intn,char*na)//查找是否存在{Student*p=equal(n);if(p==NULL){top++;read[top].addStudent(n,na);return1;}return0;}Student*equal(intStudentid)//按编号查找{for(inti=0;i<=top;i++)if(read[i].getnumber()==Studentid&&read[i].gettag()==0){return&read[i];}returnNULL;}voi7、doutput(){for(inti=0;i<=top;i++)read[i].output();}voidStudentdata();//读者库维护~RData()//析构函数,将read[]写到Student.txt文件中{fstreamfile("Student.txt",ios::out);for(inti=0;i<=top;i++)if(read[i].gettag()==0)file.write((char*)&read[i],sizeof(read[i]));file.close();}};voidRData::S8、tudentdata(){charchoice;charrname[20];intStudentid;Student*r;while(choice!='0'){cout<<"┏━━━━━━━━━━━━━┓";cout<<"┃读者维护┃";cout<<"┃━━━━━━━━━━━━━┃";cout<<"┃1.新增┃";cout<<"┃━━━━━━━━━━━━━┃";cout<<"┃2.更改┃";cout<<"┃━━━━━━━━━━━━━┃";cout<<"┃3.删除┃";cout<<"┃━━━━━━━9、━━━━━━┃";cout<<"┃4.查找┃";cout<<"┃━━━━━━━━━━━━━┃";cout<<"┃5.显示┃";cout<<"┃━━━━━━━━━━━━━┃";cout<<"┃6.全删┃";cout<<"┃━━━━━━━━━
5、dl;}};classRData{private:inttop;//读者记录指针Studentread[Reader];public:RData()//构造函数,将Student.txt读到read[]中{Students;top=-1;fstreamfile("Student.txt",ios::in);//打开一个输入文件while(1){file.read((char*)&s,sizeof(s));if(!file)break;top++;read[top]=s;}file.close();}voidclear(){top
6、=-1;}intaddStudent(intn,char*na)//查找是否存在{Student*p=equal(n);if(p==NULL){top++;read[top].addStudent(n,na);return1;}return0;}Student*equal(intStudentid)//按编号查找{for(inti=0;i<=top;i++)if(read[i].getnumber()==Studentid&&read[i].gettag()==0){return&read[i];}returnNULL;}voi
7、doutput(){for(inti=0;i<=top;i++)read[i].output();}voidStudentdata();//读者库维护~RData()//析构函数,将read[]写到Student.txt文件中{fstreamfile("Student.txt",ios::out);for(inti=0;i<=top;i++)if(read[i].gettag()==0)file.write((char*)&read[i],sizeof(read[i]));file.close();}};voidRData::S
8、tudentdata(){charchoice;charrname[20];intStudentid;Student*r;while(choice!='0'){cout<<"┏━━━━━━━━━━━━━┓";cout<<"┃读者维护┃";cout<<"┃━━━━━━━━━━━━━┃";cout<<"┃1.新增┃";cout<<"┃━━━━━━━━━━━━━┃";cout<<"┃2.更改┃";cout<<"┃━━━━━━━━━━━━━┃";cout<<"┃3.删除┃";cout<<"┃━━━━━━━
9、━━━━━━┃";cout<<"┃4.查找┃";cout<<"┃━━━━━━━━━━━━━┃";cout<<"┃5.显示┃";cout<<"┃━━━━━━━━━━━━━┃";cout<<"┃6.全删┃";cout<<"┃━━━━━━━━━
此文档下载收益归作者所有