版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、#in clude<iostream> #in clude<stri ng.h>#in clude<fstream>/圖書管理員using n ames pace std; class con trolloer private:int nu mber;int age; char n ame20;public:con trolloer();con trolloer(i nt c,i nt a,char b20); int get nu mber();int getage();char *get name();void reworkage(i nt i);voi
2、d rework name(char a20);con trolloer:c on trolloer()nu mber=0;char b20=" no one"age=0;strc py( name,b);b20)con trolloer:c on trolloer(i nt c,i nt a,char nu mber=c;age=a;strc py(n ame,b);int con trolloer:getage()return age;char*con trolloer:get name()return n ame;int con trolloer:get nu mbe
3、r()retur n nu mber;void con trolloer:reworkage(i nt i)age=i;void con trolloer:rework name(char a20)strc py(n ame,a);private:int nu mber;int age;char n ame20;char zhiye20;char borrowbook20;public:reader();reader(i nt c,i nt a,char b20,char d20,char e20); int get nu mber();int getage();char *getzhiye(
4、);char*get name();char * getborrowbook();void reworkborrowbook(char a20);reader:reader()char a20="沒有人" char b20="無(wú)職稱"char c20="沒有借書" nu mber=O;age=O;strc py( name,a);strc py (zhiye,b);strc py (borrowbook,c);reader:reader(i nt a,i nt c,char b20,char d20,char e20)nu mber=
5、a;age=c;strc py( name,b);strc py (zhiye,d);strc py (borrowbook,e);int reader:get nu mber()retur n nu mber; int reader:getage()retur n age;char *reader:getzhiye()retur n zhiye; char*reader:get name()retur n n ame;char * reader:getborrowbook()retur n borrowbook;void reader:reworkborrowbook(char a20)st
6、rc py (borrowbook,a); struct book/ 圖書int num;char n ame20; char peopi e20;void store()int i,c,b;char a20,d20; ifstream file(" num.txt"); file>>b;file.close();cout<<"現(xiàn)有的圖書個(gè)數(shù):/存入圖書信息H.cout<<b<<e ndl;cout<<"請(qǐng)輸入你要輸入的圖書信息個(gè)數(shù):"<<endl;cin> >
7、c;book *shu=new bookc;cout<<"輸入圖書信息(編號(hào),名字,作者名:)"<<endl;for(i=0;i<c;i+)cin> >shui. num;cin> >a>>d;strc py (shui. name,a);strc py (shui. peopi e,d);b+;ofstream outfile("stu.txt",ios_base:a pp);for(i=0;i<c;i+)outfile.write(char *)& shui,sizeof
8、(shui);outfile.close();cout<<"存入成功!"<<endl;ofstream tfile(" num .txt");tfile<<b;tfile.close();void outbook()/輸出圖書信息int i,h,j,g, z;char k ;ifstream tfile(" num.txt"); if(!tfile)cout<<"文件不存在!"tfile.close();cout<<"你是否想創(chuàng)建(輸入 Y或N)
9、"cin> >k;if(k='N') exit(O);else ofstream tfile(" num .txt");g=0;tfile<<g;elsecout<<"本圖書館已經(jīng)有"<<g<<"本圖書"<<endl;if(g=O)cout<<"圖書館里沒有書!"<<endl;exit(0);else book *shu=new bookg;ifstream is("stu.txt&q
10、uot;,ios_base:b in ary); if(is)for(i=0;i<g;i+)is.read(char *)& shui,sizeof(shui);for(i=O;i<g;i+)作者名”<<endl;cout<<"編號(hào)名字cout<<shui. num<<""<<shui. name<<""<<shui. peopi e<<e ndl; elsecout<<"ERROR:ca nn ot ope
11、n file'stu.txt'"<<e ndl; is.close();ifstream file("reader num .txt");if(file) file>>z; file.close(); else cout<<"沒有文件" cout<<"已有的讀者個(gè)數(shù):"cout<<z<<e ndl;cout<<"輸入你的編號(hào):"cin >>j;H.cout<<"你想借哪本書
12、(輸入編號(hào)):cin> >h;reader *people=new readerz;ifstream out("reader.txt",ios_base:b in ary); if(out)for(i=0;i<z;i+)out.read(char *)&peopl ei,sizeof( peop lei);else cout<<"ERROR:ca nn ot open file'stu.txt'"<<e ndl;out.close();peopi ej-1.reworkborrowbook
13、(shuh-1. name);cout<<"編號(hào)年齡 名字 職業(yè) 借書情況 "<<endl;cout< vpeopl ej-1.get nu mber()<<""<<peop lej-1.getage()<<""vvpeopl ej-1.get name()<<""<<peopl ej-1.getzhiye()<<""vvpeopi ej-1.getborrowbook()<<e n
14、dl;ofstream outfile("reader.txt",ios_base:b in ary);for(i=0;i<z;i+)outfile.write(char *)&peop lei,sizeof( peop lei); outfile.close();cout<<"借閱成功!H./圖書管理員信息void con troller()int b,i,d,h=0;file>>b; file.close();cout<<"圖書管理員個(gè)數(shù):"<<b<<e ndl;if
15、stream file("c on trolloernum.txt"); if(file) elsecout<<"cout<<"沒有圖書管信息理員"<<e ndl; 你是否想創(chuàng)建(請(qǐng)輸入Y或N ):H.cin>>d;if(d='y') ofstream in file("c on trolloer nu m.txt");i nfile<<h;exit(0); else exit(0);ifstream is("c on trolloer.t
16、xt",ios_base:b in ary);if(is)con trolloer *book people=new con trolloerb;for(i=0;i<b;i+)is.read(char *)&book peopi ei,sizeof(book peopi ei);for(i=0;i<b;i+)cout<<"編號(hào)年齡 名字"<<endl;cout<<book peopi ei.get nu mber()<<" "<<book peopi ei.get
17、name()<<e ndl;"<<book peopi ei.getageO<<"elsecout<<"ERROR:ca nn ot open file'stu.txt'"<<e ndl; cout<<"沒有這個(gè)文件夾"<<endl;cout<<"你是否想創(chuàng)建(請(qǐng)輸入Y或N):"cin >>d;if(d='y') ofstream in file("co ntroll
18、oer.txt");exit(0);else exit(0);is.close();void libary()system("cls"); system("color 2e"); cout<<"/圖書館的總信息H.cout<<""<<e ndl;"<<e ndl;"<<e ndl;cout<<"cout<<"學(xué)校圖書館由本部圖書館及彭州校區(qū)圖書館組成.館舍面積41048平方米"cou
19、t<<"(其中現(xiàn)有館舍面積11578平方米,在建圖書館館舍面積29470平方米),cout<<"各院系資料室面積1120平方米。學(xué)校擁有紙質(zhì)文獻(xiàn)198萬(wàn)余冊(cè),H.cout<<"生均81.17冊(cè),電子文獻(xiàn)161.7萬(wàn)余種。近三年校圖書館每年進(jìn)書量均超過(guò)15萬(wàn)冊(cè)."<<endl;void storec on troller()int i,b,c,h=0;char a20,d;ifstream file("co ntrolloernum.txt");if(file)file>>b;
20、 file.close();cout<<"已有的圖書管理員個(gè)數(shù): cout<<b<<e ndl;else/存入新的管理員的信息H.cout<<"沒有圖書管信息理員"<<endl;cout<<"你是否想創(chuàng)建(請(qǐng)輸入 y或n):cin> >d;if(d='y')ofstream in file("c on trolloer num .txt");i nfile<<h;i nfile.close();b=0; else exit(
21、0) ;ofstream outfile("c on trolloer.txt",ios:a pp);cout<<"請(qǐng)輸入圖書管理員的編號(hào)和年齡名字:"H.cin> >c>>i>>a;con trolloer book peopi e(c,i,a);cout<<"編號(hào)年齡 名字"<<endl;cout<<book peopi e.get nu mber()<<""<<book peopi e.get name
22、()<<e ndl;outfile.write(char *)&book peopi e,sizeof(book peopi e); outfile.close();b+;ofstream tfile("c on trolloer num .txt");tfile<<b;tfile.close();cout<<"保存成功!"<<book peopi e.getage()<<"H.void reworkc on trolloer()/修改圖書管理員int i,b,h,j,g;ch
23、ar d20;ifstream file("c on trolloer num .txt");if(file) file>>b; file.close(); else cout<<"沒有圖書管信息理員"exit(O);cout<<"已有的圖書管理員個(gè)數(shù):H.cout<<b<<e ndl;con trolloer *book people=new con trolloerb; ifstream is("c on trolloer.txt",ios_base:b in
24、ary);if(is)for(i=O;i<b;i+)is.read(char *)&book peopi ei,sizeof(book peopi ei); for(i=O;i<b;i+) cout<<"編號(hào)年齡 名字"<<endl;cout<<book peopi ei.get nu mber()<<""<<book peopi ei.get name()<<e ndl;else"<<book peopi ei.getage()<&l
25、t;"cout<<"ERROR:ca nn ot open file'stu.txt'"<<e ndl; is.close();cout<<"請(qǐng)輸入你要修改的管理員編號(hào):H.cin> >h;cout<<"輸入年齡,名字:";cin> >g>>d;book peopi eh-1.reworkage(g);book peopi eh-1.rework name(d);cout<<"該了后的名字:"<&l
26、t;bookpeopleh-1.getname(); ofstream tfile("c on trolloer.txt",ios_base:b in ary);for(j=0;j<b;j+)tfile.write(char *)&book peopi ej,sizeof(book peopi ej);tfile.close();_page_break_void storereader()II存入讀者信息int i,b,c,h,l=1;char f;char a20,d20,e20;ifstream file("reader nu m.txt&quo
27、t;);if(file) file>>b; file.close(); else cout<<"沒有文件" cout<<"已有的讀者個(gè)數(shù):"cout<<b<<e ndl;cout<<"如果你想重新存入(輸入 y或n):"cin >>f;if(f=' n')while(l=1) cout<<"請(qǐng)輸入讀者的編號(hào)和年齡,名字,職業(yè),借書情況:"cin> >c>>i>>a>
28、;>d>>e;reader peop le(c,i,a,d,e); cout<<"編號(hào)年齡 名字職業(yè)cout< <peop le.get nu mber()<<""vvpeopl e.get name()<<""<<peopl e.getzhiye()<<""vvpeopl e.getborrowbook()<<e ndl;ofstream outfile("reader.txt",ios_base:a
29、pp); outfile.write(char *)&peopl e,sizeof( peopi e); outfile.close();b+;cout<<"借書情況"<<e ndl;"vvpeopl e.getage()<<"你還要添加,請(qǐng)按1,不添按0 :"cin> >h;if(h=1)if(h=0)ofstream tfile("readernum.txt"); tfile<<b;tfile.close();cout<<"保存成功
30、!1=1;1=0;H. elsein t g=0;cout<<"請(qǐng)輸入讀者的編號(hào)和年齡名字,職業(yè),借書情況:"cin> >c>>i>>a>>d>>e;reader peopi e(c,i,a,d,e); cout<<"編號(hào)年齡 名字職業(yè)cout< vpeopi e.get nu mber()<<""vvpeopl e.get name()<<""<<peopl e.getzhiye()<<
31、""vvpeopl e.getborrowbook()<<e ndl;借書情況 ”<<e ndl;"vvpeopl e.getage()<<"ofstream outfile("reader.txt",ios_base:tr unc ); outfile.write(char *)&peopl e,sizeof( peopi e);outfile.close();g+;ofstream file("reader num .txt"); file<<g;cout
32、<<g;file.close();cout<<"保存成功!"void reseachallread()/讀者的總信息int i,b;ifstream file("reader nu m.txt");if(file) file>>b; file.close(); else cout<<"沒有文件 ”;exit(0); cout<<"已有的讀者個(gè)數(shù):"cout<<b<<e ndl;reader *people=new readerb;ifstre
33、am is("reader.txt",ios_base:b in ary);for(i=0;i<b;i+)is.read(char *)&peop lei,sizeof( peopi ei);for(i=0;i<b;i+)借書情況”<<e ndl;cout<<"編號(hào)年齡 名字 職業(yè)cout< vpeopl ei.get number()<<""<<peop lei.getage()<<""<<peopl ei.get name(
34、)<<""<<peopl ei.getzhiye()<<""<<peopl ei.getborrowbook()<<e ndl;elsecout<<"ERROR:ca nn ot open file'stu.txt'"<<e ndl;is.close();void choicec on troll()/管理員int q,l=1,i,h; system("cls");system("color 2e"
35、;);cout<<"cout<<"cout<<""<<e ndl;"<<e ndl;"<<e ndl;cout<<""<<"請(qǐng)輸入密碼:"cin> >i;while(l)if(i=12)cout<<"請(qǐng)選擇執(zhí)行的操作: system("cls");system("color 3e");cout<<" cou
36、t<<" cout<<" cout<<""<<e ndl;"<<e ndl;"<<e ndl;"<<"*"<<"0退出."<<"*"<<e ndl;cout<<""<<"*" <<"1查詢圖書館管理員的信息"<<"*"&l
37、t;<e ndl;cout<<""<<"*" <<"2存入新的管理員信息."<<"*"<<e ndl;cout<<""<<"*" <<"3存入圖書的信息"<<"*"<<e ndl;cout<<""<<" *" <<"4修改圖書管
38、理員的信息"<<"*"<<e ndl;cout<<""<<" *" <<"5存入讀者的信息"<<"*"<<e ndl;cout<<""<<" *" <<"6查詢讀者的總信息(借閱情況)"<<"*"<<e ndl;H.cin>>q;if(q>=0&a
39、mp;&q<7)switch(q)case 0: l=0;break;case 1:c on troller();system( "p ause");break;case 2:storec on troller(); system( "p ause");break;case 3:store(); system(” pause"); break;case 4:reworkc on trolloer(); system( "p ause");break;case 5:storereader(); system(&q
40、uot; pause"); break;case 6:reseachallread(); system( "p ause"); break;else system("cls");system("color 4e");cout<<""<<e ndl;cout<<""<<e ndl;cout<<""<<e ndl;cout<<""<<"cout&
41、lt;<""<<e ndl;cout<<""<<e ndl;"<<e ndl;輸入錯(cuò)誤請(qǐng)重新輸入!"<<e ndl;cout<<"system(" pause"); elsesystem("cls");system("color 2e");cout<<""<<e ndl;cout<<""<<e ndl;
42、cout<<""<<e ndl;cout<<""<<"密碼錯(cuò)誤"<<endl;cout<<""<<"請(qǐng)輸入正確的密碼!"<<e ndl;cout<<""<<"退出,請(qǐng)按 0,不退出,按1"<<endl;cin> >h;if(h=0)l=0;if(h=1)"<<e ndl;system(&quo
43、t;cls"); system("color 2e"); cout<<"cout<<"cout<<""<<e ndl;"<<e ndl;cout<<""<<"請(qǐng)輸入密碼:H.cin> >i;void researchbook()int i,g,h=0;char a20;ifstream tfile(" num.txt");tfile>>g;cout<&l
44、t;"本圖書館已經(jīng)有"<<g<<"本圖書"<<endl;book *shu=new bookg;if(g=0)cout<<"圖書館里沒有書!"<<endl;elseifstream is("stu.txt",ios_base:b in ary); if(is)for(i=0;i<g;i+)is.read(char *)& shui,sizeof(shui); elsecout<<"ERROR:ca nn ot open
45、file'stu.txt'"<<e ndl;is.close();cout<<"你要查找的書的名字:"cin >>a;for(i=0;i<g;i+)if(strcm p( shui. name,a)=0)cout<<"編號(hào) 名字 cout<<shui. num<<" h+;作者名"<<endl;"<<shui. name<<""<<shui. peop le<
46、<e ndl;if(h=0)cout<<"沒有你要找的書!void reseachreader()H./查詢讀者的信息int i,b,h=O;char a20;ifstream file("reader nu m.txt");if(file) file>>b; file.close(); else cout<<"沒有文件" cout<<"已有的讀者個(gè)數(shù):"cout<<b<<e ndl;reader *people=new readerb;ifstr
47、eam is("reader.txt",ios_base:b in ary);if(is)for(i=0;i<b;i+)is.read(char *)&peop lei,sizeof( peopi ei); elsecout<<"ERROR:ca nn ot open file'stu.txt'"<<e ndl; is.close();cout<<"請(qǐng)輸入你要查找讀者的名字:H.cin >>a; for(i=0;i<b;i+) if(strcm p(peopl
48、ei.get name(),a)=0)cout<<"編號(hào)年齡 名字職業(yè)借書情況"<<endl;cout< vpeopl ei.get number()<<""<<peopl ei.getage()<<""<<peopl ei.get name()<<""<<peopl ei.getzhiye()<<""vvpeopi ei.getborrowbook()<<e ndl;h
49、+;H.if(h=0)cout<<"沒有這個(gè)讀者!/學(xué)生,老師void choice peop le()int i;char l='y' while(l='y') "<<e ndl;system("cls"); system("color 3b"); coutvv"cout<<""<<e ndl;cout<<""<<e ndl;cout<<"cout<&l
50、t;""<<e ndl;"<<e ndl;cout<<""<<e ndl;cout<<"cout<<"cout<<"cout<<""<<"*"<<"0, 退出."<<"*"<<endl;輸出圖書信息."<<"*"<<endl;查詢圖書館的總信息 ."<<"*"<<e ndl; 查詢圖書."<<"*"<<endl;查詢讀者的信息."<<"*"<<e ndl;&
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 寫給軟件開發(fā)團(tuán)隊(duì)感謝信
- 學(xué)會(huì)感恩為演講稿七篇
- 大一專業(yè)期末總結(jié)(5篇)
- 學(xué)生公寓(框架)技術(shù)標(biāo)
- 人教版四年級(jí)數(shù)學(xué)下冊(cè)導(dǎo)學(xué)案-【第2課時(shí) 平均數(shù)(2)】
- 學(xué)校 社團(tuán)課 合同
- 醫(yī)院病媒生物合同
- 英國(guó)合同法的提出offer
- 道法走近老師 課件-2024-2025學(xué)年統(tǒng)編版道德與法治七年級(jí)上冊(cè)
- 熱熔膠產(chǎn)品相關(guān)行業(yè)投資規(guī)劃報(bào)告
- 《5G時(shí)代萬(wàn)物互聯(lián)》演講課件
- 24年注安-其他安全-必背考點(diǎn)-王培山
- 園林工程技術(shù)專業(yè)建設(shè)規(guī)劃
- 2024至2030年中國(guó)磷礦石行業(yè)需求領(lǐng)域及發(fā)展現(xiàn)狀調(diào)研報(bào)告
- 6個(gè)關(guān)鍵點(diǎn)!二十屆三中全會(huì)解讀課件
- 《ISO∕IEC 42001-2023信息技術(shù)-人工智能-管理體系》解讀和應(yīng)用指導(dǎo)材料(雷澤佳2024A0)
- 病案首頁(yè)填寫培訓(xùn)課件
- 淺談農(nóng)村初中學(xué)生學(xué)習(xí)數(shù)學(xué)的困境與對(duì)策
- 支付結(jié)算業(yè)務(wù)最新課件
- 孕產(chǎn)婦配偶艾滋病、梅毒檢測(cè)服務(wù)流程
- 遼沈戰(zhàn)役PPT課件
評(píng)論
0/150
提交評(píng)論