已閱讀5頁,還剩12頁未讀, 繼續(xù)免費閱讀
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)
文檔簡介
#include #include#includestatic int n=0;int comp(char*,char*);class studentpublic: void getdata() tag=#; coutnamenumberClassscore; char gettag() return tag; void disp() if(tag=#) coutsetiosflags(ios:left) setw(10)namesetw(18)numbersetw(20)Classsetw(20)scoreendl; char *getname() return name; private: char tag; char name12; char number18; char Class20; char score6;class teacherpublic: void getdata() tag=#; coutnamenumberzhichenxueyuan; char gettag() return tag; void disp() if(tag=#) coutsetiosflags(ios:left) setw(10)namesetw(18)numbersetw(20)zhichensetw(20)xueyuanendl; char *getname() return name; private: char tag; char name12; char number18; char zhichen20; char xueyuan30;class studentteacherpublic: void getdata() tag=#; coutnamenumberClassscorezhichenxueyuan; char gettag() return tag; void disp() if(tag=#) coutsetiosflags(ios:left) setw(10)namesetw(18)numbersetw(20)Classsetw(20)scoresetw(20)zhichensetw(20)xueyuanendl; char *getname() return name; private: char tag; char name12; char number18; char Class20; double score; char zhichen20; char xueyuan30;void func1() ofstream output(MyFrd.dat); student s; cout輸入數(shù)據(jù)endl; coutn; for(int i=0;in;i+) cout第i+1個學(xué)生; s.getdata(); output.write(char *)&s,sizeof(s); ; output.close();void func2() ifstream input(MyFrd.dat); student s; cout輸出數(shù)據(jù)endl; coutsetiosflags(ios:left) setw(10)姓名setw(18)身份證號碼setw(20)班級setw(6)成績endl; input.read(char *)&s,sizeof(s); while(input) s.disp(); input.read(char*)&s,sizeof(s); ; input.close();void func3() char sname10; ifstream file(MyFrd.dat); student one; file.seekg(0); coutsname; cout輸出查詢結(jié)果:endl; coutsetiosflags(ios:left) setw(10)姓名setw(18)身份證號碼setw(20)班級setw(6)成績endl; file.read(char*)&one,sizeof(one); while(file) if(comp(one.getname(),sname)=1) one.disp(); file.read(char*)&one,sizeof(one); ; file.close();void func4() fstream outapp(MyFrd.dat,ios:app); student one; cout添加數(shù)據(jù):; one.getdata(); outapp.write(char*)&one,sizeof(one); outapp.close();void func5() char sname12; int i=0; fstream outdel(MyFrd.dat,ios:in|ios:out); student one; outdel.seekg(0); coutsname; while(!outdel.eof() outdel.seekp(sizeof(student)*i); outdel.read(char *)&one,sizeof(one); if(comp(one.getname(),sname)=1&one.gettag()=#) outdel.seekp(sizeof(student) *i); outdel.put(*); i+; outdel.close();void func6() fstream outdel(student.dat,ios:in); fstream temp(temp,ios:out|ios:trunc); student s; while(!outdel.eof() outdel.read(char *)&s,sizeof(student); if(s.gettag()=#) temp.write(char *)&s,sizeof(student); outdel.close(); temp.close(); fstream outdel1(MyFrd.dat,ios:out|ios:trunc); fstream temp1(temp,ios:in); while(!temp1.eof() temp1.read(char *)&s,sizeof(student); outdel1.write(char *)&s,sizeof(student); outdel1.close(); temp1.close(); cout此記錄已物理刪除endl;void func7() ofstream output(MyFrd1.dat); teacher s; cout輸入數(shù)據(jù)endl; coutn; for(int i=0;in;i+) cout第i+1個教師; s.getdata(); output.write(char *)&s,sizeof(s); ; output.close();void func8() ifstream input(MyFrd1.dat); teacher s; cout輸出數(shù)據(jù)endl; coutsetiosflags(ios:left) setw(10)姓名setw(18)身份證號碼setw(20)職稱setw(20)學(xué)院endl; input.read(char *)&s,sizeof(s); while(input) s.disp(); input.read(char*)&s,sizeof(s); ; input.close();void func9() char sname10; ifstream file(MyFrd1.dat); teacher one; file.seekg(0); coutsname; cout輸出查詢結(jié)果:endl; coutsetiosflags(ios:left) setw(10)姓名setw(18)身份證號碼setw(20)職稱setw(20)學(xué)院endl; file.read(char*)&one,sizeof(one); while(file) if(comp(one.getname(),sname)=1) one.disp(); file.read(char*)&one,sizeof(one); ; file.close();void func0() fstream outapp(MyFrd.dat1,ios:app); teacher one; cout添加數(shù)據(jù):; one.getdata(); outapp.write(char*)&one,sizeof(one); outapp.close();void func01() char sname12; int i=0; fstream outdel(MyFrd1.dat,ios:in|ios:out); teacher one; outdel.seekg(0); coutsname; while(!outdel.eof() outdel.seekp(sizeof(teacher)*i); outdel.read(char *)&one,sizeof(one); if(comp(one.getname(),sname)=1&one.gettag()=#) outdel.seekp(sizeof(teacher) *i); outdel.put(*); i+; outdel.close();void func02() fstream outdel(teacher.dat,ios:in); fstream temp(temp,ios:out|ios:trunc); teacher s; while(!outdel.eof() outdel.read(char *)&s,sizeof(teacher); if(s.gettag()=#) temp.write(char *)&s,sizeof(teacher); outdel.close(); temp.close(); fstream outdel1(MyFrd1.dat,ios:out|ios:trunc); fstream temp1(temp,ios:in); while(!temp1.eof() temp1.read(char *)&s,sizeof(teacher); outdel1.write(char *)&s,sizeof(teacher); outdel1.close(); temp1.close(); cout此記錄已物理刪除endl;void func03() ofstream output(MyFrd2.dat); studentteacher s; cout輸入數(shù)據(jù)endl; coutn; for(int i=0;in;i+) cout第i+1個學(xué)生; s.getdata(); output.write(char *)&s,sizeof(s); ; output.close();void func04() ifstream input(MyFrd2.dat); studentteacher s; cout輸出數(shù)據(jù)endl; coutsetiosflags(ios:left) setw(10)姓名setw(18)身份證號碼setw(20)班級setw(20)成績setw(20)職稱setw(20)學(xué)院endl; input.read(char *)&s,sizeof(s); while(input) s.disp(); input.read(char*)&s,sizeof(s); ; input.close();void func05() char sname10; ifstream file(MyFrd2.dat); studentteacher one; file.seekg(0); coutsname; cout輸出查詢結(jié)果:endl; coutsetiosflags(ios:left) setw(10)姓名setw(18)身份證號碼setw(20)班級setw(6)成績endl; file.read(char*)&one,sizeof(one); while(file) if(comp(one.getname(),sname)=1) one.disp(); file.read(char*)&one,sizeof(one); ; file.close();void func06() fstream outapp(MyFrd2.dat,ios:app); studentteacher one; cout添加數(shù)據(jù):; one.getdata(); outapp.write(char*)&one,sizeof(one); outapp.close();void func07() char sname12; int i=0; fstream outdel(MyFrd2.dat,ios:in|ios:out); studentteacher one; outdel.seekg(0); coutsname; while(!outdel.eof() outdel.seekp(sizeof(studentteacher)*i); outdel.read(char *)&one,sizeof(one); if(comp(one.getname(),sname)=1&one.gettag()=#) outdel.seekp(sizeof(studentteacher) *i); outdel.put(*); i+; outdel.close();void func08() fstream outdel(studentteacher.dat,ios:in); fstream temp(temp,ios:out|ios:trunc); studentteacher s; while(!outdel.eof() outdel.read(char *)&s,sizeof(studentteacher); if(s.gettag()=#) temp.write(char *)&s,sizeof(studentteacher); outdel.close(); temp.close(); fstream outdel1(MyFrd2.dat,ios:out|ios:trunc); fstream temp1(temp,ios:in); while(!temp1.eof() temp1.read(char *)&s,sizeof(studentteacher); outdel1.write(char *)&s,sizeof(studentteacher); outdel1.close(); temp1.close(); cout此記錄已物理刪除endl;void func09() char sname10; ifstream file(MyFrd.dat); student one; file.seekg(0); coutsname; cout輸出查詢結(jié)果:endl; coutsetiosflags(ios:left) setw(10)姓名setw(18)身份證號碼setw(20)班級setw(6)成績endl; file.read(char*)&one,sizeof(one); while(file) if(comp(one.getname(),sname)=1) one.disp(); file.read(char*)&one,sizeof(one); ; file.close(); ofstream output(MyFrd.dat); student s; cout重新輸入數(shù)據(jù):endl; s.getdata(); output.write(char *)&s,sizeof(s); output.close();void func10() char sname10; ifstream file(MyFrd1.dat); teacher one; file.seekg(0); coutsname; cout輸出查詢結(jié)果:endl; coutsetiosflags(ios:left) setw(10)姓名setw(18)身份證號碼setw(20)班級setw(6)成績endl; file.read(char*)&one,sizeof(one); while(file) if(comp(one.getname(),sname)=1) one.disp(); file.read(char*)&one,sizeof(one); ; file.close(); ofstream output(MyFrd1.dat); teacher s; cout重新輸入數(shù)據(jù):endl; s.getdata(); output.write(char *)&s,sizeof(s); output.close();void func11() char sname10; ifstream file(MyFrd2.dat); studentteacher one; file.seekg(0); coutsname; cout輸出查詢結(jié)果:endl; coutsetiosflags(ios:left) setw(10)姓名setw(18)身份證號碼setw(20)班級setw(6)成績endl; file.read(char*)&one,sizeof(one); while(file) if(comp(one.getname(),sname)=1) one.disp(); file.read(char*)&one,sizeof(one); ; file.close(); ofstream output(MyFrd2.dat); studentteacher s; cout重新輸入數(shù)據(jù):endl; s.getdata(); output.write(char *)&s,sizeof(s); output.close();int comp(char s1,char s2) int i=0; while(s1i!=0&s2i!=0&s1i=s2i) i+; if(s1i=0|s2i=0) return 1; else return 0;void main() int sel; do cout請輸入(1:輸入數(shù)據(jù) 2:輸出數(shù)據(jù) 3:按姓名查詢endlsel; switch(sel) case 1: char a,b; while(1) couta; if(a=1) func1(); else if(a=2) func7(); else if(a=3) func03(); else cout輸入錯誤!endl; coutb; while(b!=y&b!=Y&b!=n&b!=N) coutb; if(b=n|b=N) break; break; case 2: char c,d; while(1) coutc; if(c=1) func2(); else if(c=2) func8(); else if(c=3) func04(); else cout輸入錯誤!endl; coutd; while(d!=y&d!=Y&d!=n&d!=N) coutd; if(d=n|d=N) break; break; case 3: char e,f; while(1) coute; if(e=1) func
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 中國政法大學(xué)《工程中的數(shù)值方法C》2023-2024學(xué)年第一學(xué)期期末試卷
- 鄭州西亞斯學(xué)院《現(xiàn)代通信原理》2023-2024學(xué)年第一學(xué)期期末試卷
- 長江工程職業(yè)技術(shù)學(xué)院《公共服務(wù)質(zhì)量管理》2023-2024學(xué)年第一學(xué)期期末試卷
- 消費級3D打印機打印精度改進
- 保險行業(yè)基礎(chǔ)講解模板
- 業(yè)務(wù)操作-房地產(chǎn)經(jīng)紀(jì)人《業(yè)務(wù)操作》名師預(yù)測卷4
- 開學(xué)晨會發(fā)言稿
- 二零二五年政府形象廣告服務(wù)合同規(guī)范
- 二零二五版國際學(xué)校外教引進與團隊建設(shè)協(xié)議3篇
- 2024-2025學(xué)年新疆烏魯木齊四十一中高二(上)期末數(shù)學(xué)試卷(含答案)
- 《道路交通安全法》課件完整版
- 向女朋友認(rèn)錯保證書范文
- 五分?jǐn)?shù)加法和減法(課件)-數(shù)學(xué)五年級下冊
- 2024年四川省綿陽市中考語文試卷(附真題答案)
- 設(shè)計材料與工藝課程 課件 第1章 產(chǎn)品設(shè)計材料與工藝概述
- 幼兒園反恐防暴技能培訓(xùn)內(nèi)容
- 食品企業(yè)質(zhì)檢員聘用合同
- 中醫(yī)診所內(nèi)外部審計制度
- 自然辯證法學(xué)習(xí)通超星期末考試答案章節(jié)答案2024年
- 2024年國家危險化學(xué)品經(jīng)營單位安全生產(chǎn)考試題庫(含答案)
- 護理員技能培訓(xùn)課件
評論
0/150
提交評論