




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、#include#include#include#include #include /using namespace std;const intcount =3;class situaction;classstudent public: int sno;char sname20; char sex3;int age;char depart20; char classno20;char lianx40;/public:friend voidsselect();friend voidsupdate();friend voidsdelet();friend voidsaccount();friend
2、 voidsdisplay();friend istream & operator (istream & in,student &stu)instu.snostu.snamestu.sexstu.agestu.departstu.classnostu.lianx; return in;friend ostream & operator ( ostream & out,student &stu)stu.departoutstu.snostu.classnostu.sname stu.lianxendl;stu.sexstu.agereturn out;friend voidfriend void
3、xkadd();sadd();voidsadd() while(1)int flag1=0;student s;cout 請(qǐng)輸入要添加的學(xué)生的學(xué)號(hào)、 姓名、 性別、年齡、系別、 班級(jí)、聯(lián)系方式 s;ifstream in(e:studentfile.txt);if(!in)cout 打開學(xué)生信息文件失?。ndl;return ;student stu;in.read(char*)&stu,sizeof(student);while(!in.eof()if(s.sno=stu.sno) flag1=1; break; in.read(char*)&stu,sizeof(student);in.
4、close();if(flag1=1) cout 該學(xué)生已經(jīng)在文件中存在不允許添加! endl; else ofstream out(e:studentfile.txt,ios:app); out.write(char*)&s,sizeof(student);out.close();system(pause);break;voidsselect() while(1)system(cls);cout*請(qǐng)選擇要查詢的類別: *endl;cout*按學(xué)生學(xué)號(hào)請(qǐng)按 1: * endl;cout*按學(xué)生姓名請(qǐng)按 2: *endl;cout*按學(xué)生系別請(qǐng)按 3: *endl;cout*按學(xué)生班級(jí)請(qǐng)按 4:
5、 *endl;cout*返回上一級(jí)界面請(qǐng)按 5: *sn;while(sn5|sn1)cout 選擇的數(shù)據(jù)無(wú)效,請(qǐng)重新輸入:sn;coutendl;ifstream in(e:studentfile.txt);if(!in)cout 打開學(xué)生信息文件失敗!endl;return ;int flag=0;switch(sn)case 1: int no;cout 請(qǐng)輸入要查詢的學(xué)生的學(xué)號(hào)no;student stu;in.read(char*)&stu,sizeof(student);while(!in.eof() if(no=stu.sno) coutstuendl; flag=1; in.r
6、ead(char*)&stu,sizeof(student);break;case 2: char name20;cout 請(qǐng)輸入要查詢的學(xué)生的姓名name;student stu;in.read(char*)&stu,sizeof(student);while(!in.eof()if(strcpy(name,stu.sname)=0)coutstuendl;flag=1;in.read(char*)&stu,sizeof(student);break;case 3:char dep20;cout 請(qǐng)輸入要查詢的學(xué)生的系別dep;student stu;in.read(char*)&stu,s
7、izeof(student);while(!in.eof() if(strcmp(dep,stu.depart)=0) coutstuendl; flag=1; in.read(char*)&stu,sizeof(student);break;case 4:char clno20;cout 請(qǐng)輸入要查詢的學(xué)生的班級(jí)clno;student stu;in.read(char*)&stu,sizeof(student);while(!in.eof()if(strcmp(clno,stu.classno)=0)coutstuendl;flag=1;in.read(char*)&stu,sizeof(
8、student);break;case 5:return ;in.close();if(flag=0) cout 要查詢的學(xué)生在文件不存在! endl; system(pause);voidsupdate()while(1)system(cls);cout* cout* cout* cout* cout* cout*請(qǐng)選擇按下列類別查詢后修改:*endl;按學(xué)生學(xué)號(hào)請(qǐng)按 1: * endl;按學(xué)生姓名請(qǐng)按 2: *endl;按學(xué)生系別請(qǐng)按 3: *endl;按學(xué)生班級(jí)請(qǐng)按 4: *endl;返回上一級(jí)界面請(qǐng)按 5: *sn;while(sn5|sn1)cout 選擇的數(shù)據(jù)無(wú)效,請(qǐng)重新輸入:sn
9、;coutendl;fstream in(e:studentfile.txt,ios:in|ios:out);if(!in)cout 打開學(xué)生信息文件失?。ndl;return ;int flag=0;switch(sn)case 1: int no;cout 請(qǐng)輸入要查詢的學(xué)生的學(xué)號(hào)no;student stu;int i=0;in.seekg(i*sizeof(student),ios:beg);in.read(char*)&stu,sizeof(student);while(!in.eof()if(no=stu.sno)coutstuendl;cout 請(qǐng)輸入要修改的學(xué)生的學(xué)號(hào)、姓名、
10、性別、年齡、系別、班級(jí)、聯(lián)系方式stu;in.seekp(i*sizeof(student),ios:beg);in.write(char*)&stu,sizeof(student);flag=1;i+;in.seekg(i*sizeof(student),ios:beg);in.read(char*)&stu,sizeof(student);break;case 2:case 3:case 4:case 5:return ;in.close();if(flag=0) cout 要修改的學(xué)生在文件不存在! endl;system(pause);voidsdelet() while(1)syst
11、em(cls);cout*請(qǐng)選擇按下列類別查詢后刪除:*endl;cout*按學(xué)生學(xué)號(hào)請(qǐng)按 1: * endl;cout*按學(xué)生姓名請(qǐng)按 2: *endl;cout*按學(xué)生系別請(qǐng)按 3: *endl;cout*按學(xué)生班級(jí)請(qǐng)按 4: *endl;cout*返回上一級(jí)界面請(qǐng)按 5: *sn;while(sn5|sn1)cout 選擇的數(shù)據(jù)無(wú)效,請(qǐng)重新輸入:sn;coutendl;student stu20;int flag=0;switch(sn)case 1: ifstream in(e:studentfile.txt);if(!in)cout 打開學(xué)生信息文件失敗!endl;return ;i
12、nt n=0;in.read(char*)&stun,sizeof(student);while(!in.eof() n+; in.read(char*)&stun,sizeof(student);in.close();int no;cout 請(qǐng)輸入要?jiǎng)h除的學(xué)生的學(xué)號(hào)no;for(int i=0;in;i+) if(no=stui.sno)coutstuiendl;cout 是否要?jiǎng)h除該學(xué)生的信息!ch;if( ch=Y|ch=y)for(int j=i;jn;j+)stuj=stuj+1;n-;flag=1;if(flag=0)cout 要 修 改 的 學(xué) 生 在 文 件 不 存 在 ! e
13、ndl;elseofstream out(e:studentfile.txt);if(!out)cout 打開學(xué)生信息文件失敗!endl;return ;for(int k=0;kn;k+)out.seekp(k*sizeof(student),ios:beg);out.write(char*)&stuk,sizeof(student);out.close();break;case 2:case 3:case 4:case 5:return ;system(pause);voidsaccount()ifstream ifs(e:studentfile.txt); if(!ifs)cout 打開
14、文件失??! ; system(pause);return ;int i=0;student s;ifs.read(char*)&s,sizeof(student);while(!ifs.eof()i+;ifs.read(char*)&s,sizeof(student);ifs.close();cout 學(xué)生: i 人 endl;ifs.close();system(pause);voidsdisplay() ifstream in(e:studentfile.txt,ios:in); if(!in)cout 打開學(xué)生信息文件失敗!endl;return ;student stu;in.read
15、(char*)&stu,sizeof(student);while(!in.eof()coutstu (istream & in, course &cou)amecou.cxzcou.zxscou.xfcou.kcxqcou.xxrs;return in;friend ostream & operator (ostream & out,course &cou) o ame cou.cxz cou.zxs cou.xf cou.kcxq cou.xxrsendl;return out;friend voidxkadd();void ca
16、dd()int flag1=0;course c;cout 請(qǐng)輸入要添加的課程的課程代碼、課程名稱、課程性質(zhì)、總學(xué)時(shí)、學(xué)分、開課學(xué)期、選修人數(shù) c;ifstream in(e:coursefile.txt);if(!in)cout 打開課程信息文件失??!endl;return ;course cou;in.read(char*)&cou,sizeof(course);while(!in.eof()if(o=o) flag1=1; break;in.read(char*)&cou,sizeof( course);in.close();if(flag1=1) cout該課程已經(jīng)
17、在文件中存在不允許添加! endl;elseofstream out(e:coursefile.txt,ios:app); out.write(char*)&c,sizeof(course);out.close();system(pause);voidcselect()while(1) system(cls);cout*請(qǐng)選擇要查詢的類別: *endl;cout*按課程編號(hào)請(qǐng)按 1: * endl;cout*按課程名稱請(qǐng)按 2: *endl;cout*返回上一級(jí)界面請(qǐng)按 3: *sn;while(sn3|sn1)cout 選擇的數(shù)據(jù)無(wú)效,請(qǐng)重新輸入:sn;coutendl;ifstream i
18、n(e:coursefile.txt);if(!in)cout 打開課程信息文件失??!endl;return ;int flag=0;switch(sn)case 1: int no;cout 請(qǐng)輸入要查詢的課程的編號(hào)no;course ke;in.read(char*)&ke,sizeof(course);while(!in.eof() if(no=o) coutkeendl; flag=1; in.read(char*)&ke,sizeof(course);/if(no=ke. char*)&ke,sizeof(course);break;case 2: char name25;
19、cout 請(qǐng)輸入要查詢的課程的名稱name;course ke;in.read(char*)&ke,sizeof(course);while(!in.eof() if(strcpy(name,ame)=0) coutkeendl; flag=1; in.read(char*)&ke,sizeof(course);break;case 3:return ;in.close();if(flag=0) cout 要查詢的課程在文件不存在! endl;system(pause);voidcupdate() while(1) system(cls);cout*請(qǐng)選擇按下列類別查詢后修改:*en
20、dl;cout*按課程編號(hào)請(qǐng)按 1: * endl;cout*按課程名稱請(qǐng)按 2: *endl;cout*按課程性質(zhì)請(qǐng)按 3: *endl;cout*按課程學(xué)分請(qǐng)按 4: *endl;cout*返回上一級(jí)界面請(qǐng)按 5: *sn;while(sn5|sn1)cout 選擇的數(shù)據(jù)無(wú)效,請(qǐng)重新輸入:sn;coutendl;fstream in(e:studentfile.txt,ios:in|ios:out);if(!in)cout 打開課程信息文件失?。ndl;return ;int flag=0;switch(sn)case 1: int no;cout 請(qǐng)輸入要查詢的課程的編號(hào)no;cour
21、se k;int i=0;in.seekg(i*sizeof(course),ios:beg);in.read(char*)&k,sizeof(course);while(!in.eof()if(no=o)coutkendl;cout 請(qǐng)輸入要修改的課程的編號(hào),名稱,性質(zhì),學(xué)分 k;in.seekp(i*sizeof(course),ios:beg);in.write(char*)&k,sizeof(course);flag=1;i+;in.seekg(i*sizeof(course),ios:beg);in.read(char*)&k,sizeof(course);break;cas
22、e 2: int no;cout 請(qǐng)輸入要查詢的學(xué)生的學(xué)號(hào)no;student stu;int i=0;in.seekg(i*sizeof(student),ios:beg);in.read(char*)&stu,sizeof(student);while(!in.eof()if(no=stu.sno)coutstuendl;cout 請(qǐng)輸入要修改的的課程的編號(hào),名稱,性質(zhì),學(xué)分 stu;in.seekp(i*sizeof(student),ios:beg);in.write(char*)&stu,sizeof(student);flag=1;i+;in.seekg(i*sizeof(stud
23、ent),ios:beg);in.read(char*)&stu,sizeof(student);break;case 3:return ;in.close();if(flag=0) cout 要修改的選課信息在文件不存在! endl;system(pause);voidcdelet()while(1)system(cls);cout*請(qǐng)選擇按下列類別查詢后刪除:*endl;cout*按課程編號(hào)請(qǐng)按 1: * endl;cout*按課程名稱請(qǐng)按 2: *endl;cout*返回上一級(jí)界面請(qǐng)按 3: *sn;while(sn3|sn1)cout 選擇的數(shù)據(jù)無(wú)效,請(qǐng)重新輸入:sn;coutendl
24、;course k20;int flag=0;switch(sn)case 1: ifstream in(e:coursefile.txt);if(!in)cout 打開課程信息文件失??!endl;return ;int n=0;in.read(char*)&kn,sizeof(course);while(!in.eof() n+; in.read(char*)&kn,sizeof(course);in.close();int no;cout 請(qǐng)輸入要?jiǎng)h除的課程的編號(hào)no;for(int i=0;in;i+) if(no=o)coutkiendl;cout 是否要?jiǎng)h除該課程的信息!c
25、h;if( ch=Y|ch=y)for(int j=i;jn;j+)kj=kj+1;n-;flag=1;if(flag=0)cout 要 修 改 的 課 程 在 文 件 不 存 在 ! endl;elseofstream out(e:coursefile.txt);if(!out)cout 打開課程信息文件失敗!endl;return ;for(int i=0;in;i+)out.seekp(i*sizeof(course),ios:beg);out.write(char*)&ki,sizeof(course);out.close();break;case 2:case 3:case 4:ca
26、se 5:return ;system(pause);voidcaccount()ifstream ifs(d:coursetfile.txt); if(!ifs)cout 打開文件失??!;system(pause);return ;int i=0;course ke;ifs.read(char*)&ke,sizeof(course);while(!ifs.eof()i+;ifs.read(char*)&ke,sizeof(course);ifs.close();cout 課程: i 門 endl;ifs.close();system(pause);voidcdisplay() ifstrea
27、m in(e:coursefile.txt); if(!in)cout 打開課程信息文件失??!endl;return ;course cou;in.read(char*)&cou,sizeof( course);while(!in.eof()cout (istream & in, situaction &si) o; si.score=0;return in;friend ostream & operator (ostream & out,situaction &si)osi.scoreendl;return out;voidxkadd()
28、 situaction xk;cout 請(qǐng)輸入要選修的學(xué)號(hào)、課程號(hào)xk;int flag1=0, flag2=0;ifstream in1(e:studentfile.txt);if(!in1)cout 打開學(xué)生信息文件失?。ndl;return ;student stu;in1.read(char*)&stu,sizeof(student);while(!in1.eof()if(xk.sno=stu.sno) flag1=1; break;in1.read(char*)&stu,sizeof(student);in1.close();if(flag1=0) cout該學(xué)生不存在不允許選課!
29、 endl;else course cou;ifstream in2(e:coursefile.txt); if(!in2)cout 打開課程文件失敗! endl;return ;in2.read(char*)&cou,sizeof(course);while(!in2.eof()if(o=o) flag2=1; break;in2.read(char*)&cou,sizeof(course);in2.close();if(flag2=0) cout該課程不存在不允許選課! endl;else situaction si;int scount=0,ccount=0;ifstream in3(e:situationfile.txt);if(!in3)cout 打開選課文件失?。ndl;return ;in3.read(char*)&si,sizeof(situaction);while(!in3.eof()if(xk.sno=si.sno) ccount+;if(o=o) scount+;in3.read(char*)&si,sizeof(situaction);in
溫馨提示
- 1. 本站所有資源如無(wú)特殊說明,都需要本地電腦安裝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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 商丘學(xué)院《建筑信息建模(BM)》2023-2024學(xué)年第二學(xué)期期末試卷
- 九江理工職業(yè)學(xué)院《動(dòng)物病毒與人類健康》2023-2024學(xué)年第二學(xué)期期末試卷
- 湖南工程學(xué)院《數(shù)據(jù)結(jié)構(gòu)與算法分析課程設(shè)計(jì)》2023-2024學(xué)年第二學(xué)期期末試卷
- 《活動(dòng)二 安全網(wǎng)上行》(教學(xué)設(shè)計(jì))-2023-2024學(xué)年六年級(jí)上冊(cè)綜合實(shí)踐活動(dòng)蒙滬版
- 遼寧現(xiàn)代服務(wù)職業(yè)技術(shù)學(xué)院《美術(shù)表現(xiàn)一中國(guó)畫》2023-2024學(xué)年第二學(xué)期期末試卷
- 海南外國(guó)語(yǔ)職業(yè)學(xué)院《自然地理基礎(chǔ)》2023-2024學(xué)年第二學(xué)期期末試卷
- 地震數(shù)據(jù)采集系統(tǒng)項(xiàng)目效益評(píng)估報(bào)告
- 山東商務(wù)職業(yè)學(xué)院《工程技術(shù)基礎(chǔ)》2023-2024學(xué)年第二學(xué)期期末試卷
- 鄭州商貿(mào)旅游職業(yè)學(xué)院《跨境電商平臺(tái)操作》2023-2024學(xué)年第二學(xué)期期末試卷
- 武漢商學(xué)院《文獻(xiàn)檢索與學(xué)術(shù)訓(xùn)練》2023-2024學(xué)年第二學(xué)期期末試卷
- 化工原理傳質(zhì)導(dǎo)論
- 環(huán)境與可持續(xù)發(fā)展ppt課件(完整版)
- Linux操作系統(tǒng)課件(完整版)
- 跨境電商亞馬遜運(yùn)營(yíng)實(shí)務(wù)完整版ppt課件-整套課件-最全教學(xué)教程
- 中國(guó)傳媒大學(xué)《當(dāng)代電視播音主持教程》課件
- 浙美版小學(xué)六年級(jí)美術(shù)下冊(cè)全冊(cè)精品必備教學(xué)課件
- DB32∕T 4245-2022 城鎮(zhèn)供水廠生物活性炭失效判別和更換標(biāo)準(zhǔn)
- 建設(shè)工程圍擋標(biāo)準(zhǔn)化管理圖集(2022年版)
- 人教版七年級(jí)上冊(cè)歷史課程綱要
- 濕法冶金簡(jiǎn)介
- 2022新教科版六年級(jí)科學(xué)下冊(cè)全一冊(cè)全部教案(共28節(jié))
評(píng)論
0/150
提交評(píng)論