


下載本文檔
版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、class Person public:char name8; ;class student:public Person/構(gòu)建學(xué)生類public:friend void Manage(student stud) ;friend void Input(student stud) ;friend void Statistic(student stud);friend void Lookup(student stud) ;friend void Modify(student stud) ;friend void Output(student stud) ;friend void Insert(stu
2、dent stud) ;friend void Write(student stud,int n);friend int Read(student stud);private:int num;char name8;char class_020;float c_program;float english;float math;float average;int order;stud100;class Manage:public student;void Write(student stud,int n) / 向文件中寫入數(shù)據(jù)fstream myFile;myFile.open("sco
3、re.txt",ios:out|ios:binary);if(!myFile)cout<<"score.txt can't open!"<<endl;abort();int count=n;myFile<<count<<endl<<endl;for(int i=0;i<=count;i+)myFile<<studi.class_0<<""<<studi.num<<""<<&
4、lt;<""<<studi.c_program<<""<<studi.english<<""<<studi.math<<""<<studi.average<<endl;myFile.close();int Read(student stud) /從文件中讀數(shù)據(jù)fstream myFile;myFile.open("score.txt",ios:in|ios:binary);if(!myFile)
5、cout<<"score.txt can't open!"<<endl;abort();int count;myFile.seekg(0);myFile>>count;for(int i=0;i<=count;i+)myFile>>studi.class_0>>studi.num>>>>studi.c_program>>studi.english>>studi.math >>studi.average;myFile.clo
6、se();return count ;void Input(student stud) /-輸入學(xué)生成績(jī)system("cls"); /*運(yùn)行前清屏 */int i=0;int flag;char sign;cout<<endl<<">>>>>>>>請(qǐng)輸入學(xué)生成績(jī)<<<<<<<<n"<<endl;while(sign!='n'&&sign!='N') /*判斷 */cout&l
7、t;<" 班級(jí) :" /*交互輸入 */cin>>studi.class_0;loop:cout<<" 學(xué)號(hào) :"cin>>studi.num;int c=0;while(c<i)c+;if(studi.num=studi-c.num)cout<<" 你輸入的學(xué)號(hào)已經(jīng)存在! 請(qǐng)重新輸入 !"<<endl;goto loop;cout<<" 姓名 :"cin>>;doflag=0;cout<<
8、;"C+成績(jī) :"cin>>studi.c_program;if(studi.c_program>100 |studi.c_program<1)cout<<"請(qǐng)輸入 1-100 之間的數(shù)字 !n"elseflag=1;while(flag=0);doflag=0;cout<<" 英語(yǔ)成績(jī) :"cin>>studi.english;if(studi.english>100 |studi.english<1)cout<<"請(qǐng)輸入 1-100 之間
9、的數(shù)字 !n"elseflag=1;while(flag=0);doflag=0;cout<<" 數(shù)學(xué)成績(jī) :"cin>>studi.math;if(studi.math>100 |studi.math<1)cout<<"請(qǐng)輸入 1-100 之間的數(shù)字 !n"elseflag=1;while(flag=0);studi.average=(studi.c_program+studi.english+studi.math)/3;cout<<" 平均分: "<<
10、;studi.average<<endl;cout<<" 繼續(xù)錄入學(xué)生成績(jī)?(y/n)"cin>>sign; /*輸入判斷*/i+;Write(stud,i);void Statistic(student stud)/-統(tǒng)計(jì)學(xué)生數(shù)據(jù)system("cls"); /*運(yùn)行前清屏*/int n=Read(stud);cout<<endl<<">>>>>>>>顯示學(xué)生成績(jī)<<<<<<<<n&quo
11、t;<<endl;cout<<"班級(jí) "<<"t"<<"學(xué)號(hào) "<<"t"<<"姓名 "<<"t "<<"平均分 "<<endl;for(int i=0;i<n;i+)cout<<studi.class_0<<"t"<<studi.num<<"t"<&
12、lt;<<"t"<<studi.average<<endl;system("pause");void Lookup(student stud) /-查找學(xué)生成績(jī)int p;cout<<"請(qǐng)選擇 1. 按學(xué)號(hào)查找2.按姓名查找 "<<endl;cin>>p;if(p=1)system("cls"); /*運(yùn)行前清屏 */int n=Read(stud);int s;int i=0;cout<<endl<<
13、;">>>>>>>>查找學(xué)生成績(jī)<<<<<<<<n"<<endl;cout<<" 請(qǐng)輸入查找學(xué)生的學(xué)號(hào):"<<endl;cin>>s;while(studi.num-s)!=0&&i<n) i+; /*查找判斷 */if(i=n)cout<<" 沒(méi)有該學(xué)生的信息!"<<endl; /*輸入失敗信息 */elsecout<<"-
14、"<<endl;cout<<" 班級(jí) :"<<studi.class_0<<endl; /*輸出該學(xué)生信息 */cout<<" 學(xué)號(hào) :"<<studi.num<<endl;cout<<" 姓名 :"<<<<endl;cout<<"C+:"<<studi.c_program<<endl;cout<<" 英語(yǔ) :
15、"<<studi.english<<endl;cout<<" 數(shù)學(xué) :"<<studi.math<<endl;cout<<" 平均分 :"<<studi.average<<endl;if(p=2)system("cls"); /*運(yùn)行前清屏 */int m=Read(stud);char t;int i=0;cout<<endl<<">>>>>>>>
16、查找學(xué)生成績(jī)<<<<<<<<n"<<endl;cout<<" 請(qǐng)輸入查找學(xué)生的姓名:"<<endl;cin>>t;while(strcmp(-t,)=0&&i<m) i+; /*查找判斷*/cout<<"-"<<endl;cout<<"班級(jí) :"<<studi.class_0<<endl; /*輸出該學(xué)生信息*
17、/cout<<" 學(xué)號(hào) :"<<studi.num<<endl;cout<<" 姓名 :"<<<<endl;cout<<"C+:"<<studi.c_program<<endl;cout<<" 英語(yǔ) :"<<studi.english<<endl;cout<<" 數(shù)學(xué) :"<<studi.math<<
18、;endl;cout<<" 平均分 :"<<studi.average<<endl;void Modify(student stud)/-修改學(xué)生成績(jī)system("cls"); /*運(yùn)行前清屏*/int n=Read(stud);int s,a; float q;int i=0;cout<<endl<<">>>>>>>>修改學(xué)生成績(jī)<<<<<<<<n"<<endl;c
19、out<<" 輸入修改成績(jī)學(xué)生的學(xué)號(hào):"<<endl;cin>>s;while(studi.num-s)!=0&&i<n) i+; /*查找判斷*/if(i=n)cout<<"沒(méi)有該學(xué)生的成績(jī)!"<<endl; /*輸入失敗信息*/elsecout<<"-該學(xué)生的信息-n"<<endl; /*格式頭*/cout<<"班級(jí)"<<"t"<<"學(xué)號(hào)&q
20、uot;<<"t"<<"姓名"<<"t"<<"c+"<<"t"<<"英語(yǔ) "<<"t"<<"數(shù)學(xué) "<<"t"<<"平均分"<<endl;cout<<"-"<<endl;cout<<studi.class_0&l
21、t;<"t"<<studi.num<<"t"<<<<"t"<<studi.c_program<<"t"<<studi.english<<"t"<<studi.math<<"t"<<studi.average<<endl;cout<<"-"<<endl;cout<
22、;<" 請(qǐng)輸入要修改的課程號(hào)"<<endl;cout<<"1.c語(yǔ)言 2. 英語(yǔ) 3. 數(shù)學(xué) "<<endl;cin>>a;cout<<" 重新輸入分?jǐn)?shù) "<<endl;cin>>q;if(a=1) studi.c_program=q;if(a=2)studi.english=q;if(a=3)studi.math=q;studi.average=(studi.c_program+studi.english+studi.math)/3;cout&
23、lt;<"-該學(xué)生的信息 -n"<<endl; /*格式頭 */cout<<"班級(jí)"<<"t"<<"學(xué)號(hào)"<<"t"<<"姓名"<<"t"<<"c+"<<"t"<<"英語(yǔ) "<<"t"<<"數(shù)學(xué) "<&l
24、t;"t"<<"平均分 "<<endl;cout<<"-"<<endl;cout<<studi.class_0<<"t"<<studi.num<<"t"<<<<"t"<<studi.c_program<<"t"<<studi.english<<"t"&
25、lt;<studi.math<<"t"<<studi.average<<endl;char c;cout<<"是否保存數(shù)據(jù) ?(y/n)"<<endl;cin>>c;if(c!='n'&&c!='N')Write(stud,n);void Insert(student stud) /-增加學(xué)生成績(jī)system("cls"); /*運(yùn)行前清屏 */int n=Read(stud);char s;cout<&
26、lt;endl<<"*插入學(xué)生成績(jī) *n"<<endl;while(s!='n'&&s!='N')cout<<" 班級(jí) :"<<endl; /*交互輸入 */cin>>studn.class_0;cout<<"學(xué)號(hào) :"cin>>studn.num;cout<<"姓名 :"cin>>;cout<<"C+成績(jī) :"
27、;cin>>studn.c_program;cout<<"英語(yǔ)成績(jī) :"cin>>studn.english;cout<<"數(shù)學(xué)成績(jī) :"cin>>studn.math;studn.average=(studn.c_program+studn.english+studn.math)/3;cout<<" 平均分 "<<studn.average;n+;cout<<" 插入成功! "<<endl; /*返回成功信
28、息 */cout<<" 是否繼續(xù)輸入 (y/n)"<<endl;cin>>s;Write(stud,n);void Manage(student stud) /-按平均分對(duì)學(xué)生成績(jī)記錄項(xiàng)進(jìn)行降序排序system("cls"); /*運(yùn)行前清屏 */int i,j,k;float s;char t20;cout<<endl<<"*排列管理成績(jī)*n"<<endl;int n=Read(stud);for(i=0;i<n-1;i+) /*冒泡法排序 */for(j
29、=0;j<n-1-i;j+)if(studj.average<studj+1.average)strcpy(t,studj+1.class_0);strcpy(studj+1.class_0,studj.class_0);strcpy(studj.class_0,t);k=studj+1.num;studj+1.num=studj.num;studj.num=k;strcpy(t,studj+1.name);strcpy(studj+1.name,);strcpy(,t);s=studj+1.c_program;studj+1.c_progr
30、am=studj.c_program;studj.c_program=s;s=studj+1.english;studj+1.english=studj.english;studj.english=s;s=studj+1.math;studj+1.math=studj.math;s=studj+1.average;studj+1.average=studj.average;studj.average=s;cout<<"-"<<endl; /*格式頭 */cout<<"班 級(jí)"<<"t"&
31、lt;<"學(xué) 號(hào)"<<"t"<<"姓 名"<<"t"<<"C+"<<"t"<<"英語(yǔ)"<<"t"<<"數(shù)學(xué)"<<"t"<<"平均分"<<"t"<<"名次 "<<endl;for(
32、i=0;i<n;i+) /*循環(huán)輸入*/studi.order=i+1;cout<<studi.class_0<<"t"<<studi.num<<"t"<<<<"t"<<studi.c_program<<"t"<<studi.english<<"t"<<studi.math<<"t"<<studi
33、.average<<"t "<<studi.order<<endl;Write(stud,n);void Output(student stud) /- 顯示全部學(xué)生成績(jī)system("cls"); /*運(yùn)行前清屏*/int n=Read(stud);cout<<"*顯示班級(jí)學(xué)生成績(jī)*n"<<endl;if(!stud)cout<<" 沒(méi)有記錄 "elsecout<<"-"<<endl; /*格式頭
34、*/cout<<"班 級(jí) "<<"t"<<"學(xué) 號(hào) "<<"t"<<"姓 名"<<"t"<<"c+"<<"t"<<"英語(yǔ) "<<"t"<<"數(shù)學(xué) "<<"t"<<"平均分 "<&
35、lt;endl;for(int i=0;i<n;i+) /*循環(huán)輸入 */cout<<studi.class_0<<"t"<<studi.num<<"t"<<<<"t"<<studi.c_program<<"t"<<studi.english<<"t"<<studi.math<<"t"<<stud
36、i.average<<endl;cout<<"-"<<endl;int menu() /*菜單函數(shù) */char c;dosystem("cls"); /*運(yùn)行前清屏 */cout<<"*n"<<endl;cout<<"-歡 迎 使 用 學(xué) 生 成 績(jī) 管 理 系 統(tǒng)-n"<<endl;cout<<"$"<<endl;cout<<"*【1】輸入學(xué)生成績(jī)* "<<endl;cout<<"*【 2 】顯示學(xué)生成績(jī)*"<<endl;cout<
溫馨提示
- 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ù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 四年級(jí)科學(xué)上冊(cè)10常見(jiàn)的力教案2冀教版
- 2025年疊片機(jī)項(xiàng)目發(fā)展計(jì)劃
- 2024浙江金華田園智城人力資源有限公司招聘勞動(dòng)合同制人員2人筆試參考題庫(kù)附帶答案詳解
- 2024福建南平市武夷山水品牌運(yùn)營(yíng)管理有限公司招聘4人筆試參考題庫(kù)附帶答案詳解
- 科技倫理問(wèn)題分析4篇
- 自動(dòng)控制原理知到課后答案智慧樹(shù)章節(jié)測(cè)試答案2025年春青島大學(xué)
- 防火涂料施工方案
- 2024廣東珠海市南泓產(chǎn)業(yè)投資有限公司招聘總筆試參考題庫(kù)附帶答案詳解
- 2024年湖南省婁底經(jīng)濟(jì)技術(shù)開(kāi)發(fā)投資建設(shè)集團(tuán)有限公司公開(kāi)招聘筆試參考題庫(kù)附帶答案詳解
- 2024年西安水務(wù)(集團(tuán))有限責(zé)任公司招聘情況及筆試筆試參考題庫(kù)附帶答案詳解
- 新人教版五年級(jí)上冊(cè)數(shù)學(xué)應(yīng)用題大全doc
- 2023年新改版教科版四年級(jí)下冊(cè)科學(xué)精編練習(xí)題(含單元+期中+期末測(cè)試卷)
- 2021年劍橋國(guó)際少兒英語(yǔ)KidsBox2文本
- GB/T 6967-2009工程結(jié)構(gòu)用中、高強(qiáng)度不銹鋼鑄件
- 公司發(fā)文登記表模板
- 法考-01刑法-案例指導(dǎo)用書【】
- 《考古學(xué)》第二章-田野考古課件
- 膀胱鏡檢查記錄
- 檔案銷毀清冊(cè)
- 固體物理21固體的結(jié)合課件
- 水平定向鉆施工規(guī)范方案
評(píng)論
0/150
提交評(píng)論