版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
C實(shí)現(xiàn)簡(jiǎn)單的學(xué)生信息標(biāo)準(zhǔn)管理系統(tǒng)控制臺(tái)程序//:Definestheentrypointfortheconsoleapplication.//#include""#include<cstring>#include<iostream>#include<>#include<vector>#include<algorithm>classStudent{private:charidNumber[13];//學(xué)號(hào) charname[30];//姓名 charaddress[50];//地址 chartelephone[14];//電話號(hào)碼 intgradeMath;//數(shù)學(xué)成績(jī) intgradePhysics;//物理成績(jī) intgradeEnglish;//英語成績(jī) doublegradeMaPhEgAverage;//物數(shù)外平均 intrankGrade;//成績(jī)排名 intgradeClassmate;//同學(xué)評(píng)分 intgradeTeacher;//老師評(píng)分 intgradeEthic;//道德評(píng)分 doublegradeAll;//綜合成績(jī) intrankAll;//綜合排名public: Student();//默認(rèn)構(gòu)造函數(shù) voidStudent_WritePersonalInformation(char*iD,char*nam,char*add,char*tel);//更改學(xué)生信息 voidStudent_WriteMaPhEgGrade(intgraMa,intgraPh,intgraEg);//更改學(xué)生考試成績(jī) voidStudent_WriteOtherGrade(intgraCl,intgraTe,intgraEth);//更改學(xué)生其他成績(jī) voidStudent_DisplayInformation();//顯示學(xué)生信息 char*Student_ReadID(); doubleStudent_ReadGrade(); doubleStudent_ReadTotalGrade(); intStudent_ReadGradeRank(); intStudent_ReadTotalGradeRank(); voidStudent_WriteGradeRank(intranGr);//更改學(xué)生成績(jī)排名 voidStudent_WriteTotalGradeRank(intranAl);//更改學(xué)生綜合排名 char*Student_ReadName();};Student::Student()//默認(rèn)構(gòu)造函數(shù){ strncpy_s(idNumber,"000000000000",12); strncpy_s(name,"空",30); strncpy_s(address,"空",50); strncpy_s(telephone,"空",14);//電話號(hào)碼 gradeMath=0;//數(shù)學(xué)成績(jī) gradePhysics=0;//物理成績(jī) gradeEnglish=0;//英語成績(jī) gradeMaPhEgAverage=0;//物數(shù)外平均 rankGrade=0;//成績(jī)排名 gradeClassmate=0;//同學(xué)評(píng)分 gradeTeacher=0;//老師評(píng)分 gradeEthic=0;//道德評(píng)分gradeAll=0;//綜合成績(jī) rankAll=0;//綜合排名}voidStudent::Student_WritePersonalInformation(char*iD,char*nam,char*add,char*tel){ strncpy_s(idNumber,iD,12); strncpy_s(name,nam,30); strncpy_s(address,add,50); strncpy_s(telephone,tel,14);}voidStudent::Student_WriteMaPhEgGrade(intgraMa,intgraPh,intgraEg){ gradeMath=graMa; gradePhysics=graPh; gradeEnglish=graEg; gradeMaPhEgAverage=(gradeMath+gradePhysics+gradeEnglish)/3;}voidStudent::Student_WriteOtherGrade(intgraCl,intgraTe,intgraEth){ gradeClassmate=graCl; gradeTeacher=graTe; gradeEthic=graEth; gradeAll=gradeMaPhEgAverage*+gradeClassmate*+gradeEthic*+gradeTeacher*;}voidStudent::Student_WriteGradeRank(intranGr){ rankGrade=ranGr;}voidStudent::Student_WriteTotalGradeRank(intranAl){ rankAll=ranAl;}voidStudent::Student_DisplayInformation(){ usingnamespacestd; cout<<"-------------------------------------"<<endl; cout<<"學(xué)生信息"<<endl; cout<<"姓名:"<<name<<endl <<"學(xué)號(hào):"<<idNumber<<endl <<"地址:"<<address<<endl <<"電話:"<<telephone<<endl <<"數(shù)學(xué)成績(jī):"<<gradeMath<<endl <<"物理成績(jī):"<<gradePhysics<<endl <<"英語成績(jī):"<<gradeEnglish<<endl <<"三科平均成績(jī):"<<gradeMaPhEgAverage<<endl <<"學(xué)習(xí)成績(jī)排名:"<<rankGrade<<endl <<"同學(xué)評(píng)價(jià)得分:"<<gradeClassmate<<endl <<"教師評(píng)價(jià)得分:"<<gradeTeacher<<endl <<"道德修養(yǎng)評(píng)分:"<<gradeEthic<<endl <<"綜合成績(jī):"<<gradeAll<<endl <<"綜合成績(jī)排名:"<<rankAll<<endl; cout<<"--------------------------------------"<<endl;}char*Student::Student_ReadID(){ returnidNumber;}doubleStudent::Student_ReadGrade(){ returngradeMaPhEgAverage;}doubleStudent::Student_ReadTotalGrade(){ returngradeAll;}intStudent::Student_ReadGradeRank(){ returnrankGrade;}intStudent::Student_ReadTotalGradeRank(){ returnrankAll;}namespacestudentInformation{ std::vector<Student>studentVector; intflagStudentChoose=0; intflagStudentFound=1;}char*Student::Student_ReadName(){ returnname;}//-----------------------以上是基本數(shù)據(jù)結(jié)構(gòu)的定義,同時(shí)定義了對(duì)數(shù)據(jù)的基本操作。定義完畢了,接下來是功能函數(shù)--------------------voidMainMenu();voidEditMenu();voidAddStudentPersonalInformation(intmode);voidModifyStudentInformation();voidSearchStudent();voidDeleteStudentInformation();voidDisplayStudentInformation();voidRankByGrade();voidRankByTotalGrade();voidRankByID();boolCmpGrade(Studentstudent1,Studentstudent2);//這個(gè)函數(shù)的參數(shù)是兩個(gè)Student類的對(duì)象boolCmpTotalGrade(Studentstudent1,Studentstudent2);boolCmpID(Studentstudent1,Studentstudent2);voidDisplayAllStudentInformation();//-----------------------以下是主菜單界面函數(shù)-------------------------------------------------------------------------------voidMainMenu(){ intflagOperateInformation=1; while(flagOperateInformation) { usingnamespacestd; cout<<"-----------------------------------------------------"<<endl; cout<<"."<<endl<<endl; cout<<"按下1:進(jìn)入學(xué)生信息管理系統(tǒng)."<<endl; cout<<"按下0:退出."<<endl; cout<<"-----------------------------------------------------"<<endl<<endl<<endl; cin>>flagOperateInformation; (); cout<<endl; if(flagOperateInformation) EditMenu(); }}//------------------------主菜單界面函數(shù)定義完畢--------------------------------------------------------------------------//------------------------以下是編輯界面函數(shù)------------------------------------------------------------------------------voidEditMenu(){ intflagContinueOperation=1; while(flagContinueOperation) { flagContinueOperation=0; usingnamespacestd; cout<<"--------------------------------------------"<<endl; cout<<"主菜單"<<endl; cout<<"按下1:添加學(xué)生信息."<<endl; cout<<"按下2:修改學(xué)生信息."<<endl; cout<<"按下3:刪除學(xué)生信息."<<endl; cout<<"按下4:顯示學(xué)生信息."<<endl; cout<<"按下5:按學(xué)號(hào)升序排序"<<endl; cout<<"按下6:讀入已有信息(暫時(shí)沒實(shí)現(xiàn))"<<endl; cout<<"按下7:將信息輸出(暫時(shí)沒實(shí)現(xiàn))"<<endl; cout<<"按下8:顯示系統(tǒng)內(nèi)所有學(xué)生的信息"<<endl; cout<<"按下0:返回上一級(jí)."<<endl; cout<<"--------------------------------------------"<<endl<<endl; cin>>flagContinueOperation; (); cout<<endl; switch(flagContinueOperation) { case1:AddStudentPersonalInformation(1);break; case2:ModifyStudentInformation();break; case3:DeleteStudentInformation();break; case4:DisplayStudentInformation();break; case5:RankByID();break; case6:cout<<"功能暫未實(shí)現(xiàn)"<<endl;break; case7:cout<<"功能暫未實(shí)現(xiàn)"<<endl;break; case8:DisplayAllStudentInformation();break; case0:break; } }}//-----------------------------------------------------------------------------------------------------------------------//-----------------------以下是添加信息的界面----------------------------------------------------------------------voidAddStudentPersonalInformation(intmode){ usingnamespacestd; intflagAddPersonalInformation; intflagAddGrade; intfalgAddOtherGrade; Studentstudent1; studentInformation::(student1); intcurrentObjectPosition; if(mode==1) currentObjectPosition=studentInformation::()-1; else currentObjectPosition=studentInformation::flagStudentChoose; //-------------------------------------------------------------------------- cout<<"請(qǐng)依次添加基本信息、學(xué)習(xí)成績(jī)和其他成績(jī),且不要使用空格"<<endl; cout<<"-------------------------------------"<<endl; cout<<"基本信息"<<endl; cout<<"按下1:錄入學(xué)生基本信息;"<<endl <<"按下0:跳過基本信息。"<<endl <<"--------------------------------------"<<endl; cin>>flagAddPersonalInformation; (); if(flagAddPersonalInformation) { charname[30]; chariD[13]; charaddress[50]; charphone[14]; cout<<"請(qǐng)輸入學(xué)生姓名:"; cin>>name; (); cout<<"請(qǐng)輸入學(xué)生學(xué)號(hào):"; cin>>iD; (); cout<<"請(qǐng)輸入學(xué)生地址:"; cin>>address; (); cout<<"請(qǐng)輸入學(xué)生電話:"; cin>>phone; (); studentInformation::studentVector[currentObjectPosition].Student_WritePersonalInformation(iD,name,address,phone); cout<<"基本信息輸入成功!"<<endl <<"------------------------------"<<endl; } //------------------------------------------------------------------------------------ cout<<"-------------------------------------"<<endl; cout<<"學(xué)習(xí)成績(jī)"<<endl; cout<<"按下1:錄入學(xué)生學(xué)習(xí)成績(jī);"<<endl <<"按下0:跳過學(xué)習(xí)成績(jī)信息。"<<endl <<"--------------------------------------"<<endl; cin>>flagAddGrade; (); if(flagAddGrade) { intmathGrade; intphysicsGrade; intenglishGrade; cout<<"請(qǐng)輸入數(shù)學(xué)成績(jī):"; cin>>mathGrade; (); cout<<"請(qǐng)輸入物理成績(jī):"; cin>>physicsGrade; (); cout<<"請(qǐng)輸入英語成績(jī):"; cin>>englishGrade; (); studentInformation::studentVector[currentObjectPosition].Student_WriteMaPhEgGrade(mathGrade,physicsGrade,englishGrade); cout<<"學(xué)習(xí)成績(jī)輸入成功!"<<endl <<"------------------------------"<<endl; } //--------------------------------------------------------------- cout<<"-------------------------------------"<<endl; cout<<"其他成績(jī)"<<endl; cout<<"按下1:錄入學(xué)生其他成績(jī);"<<endl <<"按下0:跳過其他成績(jī)信息。"<<endl <<"--------------------------------------"<<endl; cin>>flagAddGrade; (); if(flagAddGrade) { intpeerGrade; intteacherGrade; intethicGrade; cout<<"請(qǐng)輸入同學(xué)評(píng)議成績(jī):"; cin>>peerGrade; (); cout<<"請(qǐng)輸入教師評(píng)議成績(jī):"; cin>>teacherGrade; (); cout<<"請(qǐng)輸入道德測(cè)評(píng)成績(jī)成績(jī):"; cin>>ethicGrade; (); studentInformation::studentVector[currentObjectPosition].Student_WriteOtherGrade(peerGrade,teacherGrade,ethicGrade); cout<<"其他成績(jī)輸入成功!"<<endl <<"------------------------------"<<endl; } RankByGrade(); RankByTotalGrade(); cout<<"學(xué)生成績(jī)錄入成功!"<<endl; cout<<"-------------------------------------"<<endl<<endl;}voidSearchStudent(){ usingnamespacestd; usingnamespacestudentInformation; charID[13]; cout<<"請(qǐng)輸入學(xué)生的學(xué)號(hào):"<<endl; cin>>ID; (); cout<<"------------------------------"<<endl; intvectorSize=(); inti=0; while((i<vectorSize)&(flagStudentFound!=0)) { flagStudentFound=strcmp(ID,studentVector[i].Student_ReadID()); i=i+1; } if(flagStudentFound==0) { flagStudentChoose=i-1; flagStudentFound=1; cout<<"您所查找的學(xué)生信息如下:"<<endl; studentVector[flagStudentChoose].Student_DisplayInformation(); } else { cout<<"未找到該學(xué)生"<<endl; }}voidModifyStudentInformation(){ usingnamespacestd; usingnamespacestudentInformation; intsearchVectorSize=(); if(searchVectorSize==0) { cout<<"---------------------------------------"<<endl; cout<<"當(dāng)前系統(tǒng)中沒有學(xué)生信息,請(qǐng)先添加學(xué)生信息!"<<endl; cout<<"---------------------------------------"<<endl; } else { SearchStudent(); cout<<"您想對(duì)該學(xué)生的信息進(jìn)行修改嗎?"<<endl; cout<<"按下1:是的。"<<endl; cout<<"按下0:放棄修改。"<<endl; cout<<"---------------------------------------"<<endl; intflagModify; cin>>flagModify; (); if((flagModify==1)&(flagStudentFound==0)) { AddStudentPersonalInformation(2); } }}voidDeleteStudentInformation(){ usingnamespacestd; usingnamespacestudentInformation; intdeleteVectorSize=(); if(deleteVectorSize==0) { cout<<"---------------------------------------"<<endl; cout<<"當(dāng)前系統(tǒng)中沒有學(xué)生信息,請(qǐng)先添加學(xué)生信息!"<<endl; cout<<"---------------------------------------"<<endl; } else { SearchStudent(); cout<<"您想刪除該學(xué)生的信息嗎?"<<endl; cout<<"按下1:刪除。"<<endl; cout<<"按下0:取消。"<<endl; cout<<"---------------------------------------"<<endl; intflagModify; cin>>flagModify; (); if((flagModify==1)&(flagStudentFound==0)) { std::vector<Student>::iteratoriter=()+flagStudentChoose;//這樣就選中了一個(gè)查到的元素 (iter); } cout<<"學(xué)生信息刪除成功!"<<endl <<"----------------------------------"<<endl; }}voidDisplayStudentInformation(){ usingnamespacestd; usingnamespacestudentInformation; intdisplayVectorSize=(); if(displayVectorSize==0) { cout<<"---------------------------------------"<<endl; cout<<"當(dāng)前系統(tǒng)中沒有學(xué)生信息,請(qǐng)先添加學(xué)生信息!"<<endl; cout<<"---------------------------------------"<<endl; } else { SearchStudent(); if(flagStudentFound==0) studentVector[flagStudentChoose].Student_DisplayInformation(); }}boolCmpGrade(Studentstudent1,Studentstudent2){ return()>();//如果student1成績(jī)大于student2,}voidRankByGrade(){ usingnamespacestudentInformation; usingnamespacestd; intrankVectorSize=(); if(rankVectorSize==1) { studentVector[0].Student_WriteGradeRank(1); } else { sort((),(),CmpGrade);//使用sort必須加上#includealgorithm和std。sort的前兩個(gè)參數(shù)是指針 inti=0; for(i=0;i<=rankVectorSize-1;i++) { if((i>=1)&&(studentVector[i].Student_ReadGrade()==studentVector[i-1].Student_ReadGrade())) studentVector[i].Student_WriteGradeRank(studentVector[i-1].Student_ReadGradeRank()); else studentVector[i].Student_WriteGradeRank(i+1); } }}boolCmpTotalGrade(Studentstudent1,Studentstudent2){ return()>();//如果student1成績(jī)大于student2,}voidRankByTotalGrade(){ usingnamespacestudentInformation; usingnamespacestd; intrankVectorSize=(); if(rankVectorSize==1) { studentVector[0].Student_WriteTotalGradeRank(1); } else { sort((),(),CmpGrade);//使用sort必須加上#includealgorithm和std。sort的前兩個(gè)參數(shù)是指針 inti=0; for(i=0;i<=rankVectorSize-1;i++) { if((i>=1)&&(studentVector[i].Student_ReadTotalGrade()==studentVector[i-1].Student_ReadTotalGrade())) studentVector[i].Student_WriteTotalGradeRank(studentVector[i-1].Student_ReadTotalGradeRank()); else studentVector[i].Student_WriteTotalGradeRank(i+1); } }}boolCmpID(Studentstudent1,Studentstudent2){ intresult; result=strcmp((),()); if(result<0) returntrue; else returnfalse;}voidRankByID(){ usingnamespacestudentInformation; usingnamespacestd; intrankVectorSize=(); sort((),(),CmpID); cout<<"-----------------------------------"<<endl; cout<<"排序成功!"<<endl; cout<<"-----------------------------------"<<endl;}voidDisplayAllStudentInformation(){ usingnamespacestd; usingnamespacestudentInformation; intdisplayVectorSize=(); inti; if(displayVectorSize==0) { cout<<"------------------------"<<endl; cout<<"當(dāng)前系統(tǒng)中沒有學(xué)生信息!"<<endl; cout<<"------------------------"<<endl; } else { cout<<"--------------------------------------------------------"<<endl; cout<<"姓名學(xué)號(hào)綜合成績(jī)綜合排名"<<endl; for(i=0;i<displayVectorSize;i++) { cout<<studentVector[i].Student_ReadName()<<"" <<studentVector[i].Student_ReadID()<<"" <<studentVector[i].Student_ReadTotalGrade()<<"" <<studentVector[i].Student_ReadTotalGradeRank()<<endl; } cout<<"--------------------------------------------------------"<<endl; }}//-----------------------以下是主函數(shù)-------------------------------------------------------------------------------------voidmain(){ MainMenu();}/*----------------------------------------------------------------------------------------下面的這是一個(gè)排序函數(shù),用到了冒泡排序法,但是程序沒用到。上面的排序用了sort()函數(shù)來實(shí)現(xiàn),功能是一樣的。*//*voidRankByGrade(){usingnamespacestudentInformation;usingnamespacestd;intflagCompareOut=0;intflagCompareIn=0;intrankVectorSize;rankVectorSize=();if(rankVectorSize==0){cout<<"---------------------------------"<<endl<<"系統(tǒng)當(dāng)前沒有學(xué)生信息!"<<endl<<"---------------------------------"<<endl;}elseif(rankVectorSize==1){studentVector[flagCompareOut].Student_WriteGradeRank(flagCompareOut+1);}else{intflagCompareOut=0;intflagCompareIn=0;for(flagCompareOut=0;flagCompareOut<rankVectorSize-1;flagCompareOut++){for(flagCompareIn=0;flagCompareIn<rankVectorSize-flagCompareOut-1;flagCompareIn++){if(studentVector[flagCompareIn].Student_ReadGrade()<studentVector[flagCompareIn+1].Student_ReadGrade()){StudentstudentTemp;studentTemp=studentVector[flagCompareIn];studen
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024年某服裝設(shè)計(jì)與某紡織廠關(guān)于環(huán)保材料應(yīng)用的合作協(xié)議
- 2024-2030年中國衛(wèi)生消毒場(chǎng)運(yùn)行狀況及投資發(fā)展前景預(yù)測(cè)報(bào)告
- 2024年度養(yǎng)老機(jī)構(gòu)與專業(yè)護(hù)理團(tuán)隊(duì)合作協(xié)議3篇
- 2024上海應(yīng)屆生落戶離職賠償金計(jì)算及協(xié)議3篇
- 2024年版房地產(chǎn)項(xiàng)目開發(fā)合作合同樣本版B版
- 珠海城市職業(yè)技術(shù)學(xué)院實(shí)訓(xùn)室安全事故應(yīng)急處置管理辦法(已發(fā)文)
- 滿洲里俄語職業(yè)學(xué)院《軟件工程原理與應(yīng)用》2023-2024學(xué)年第一學(xué)期期末試卷
- 2025技術(shù)咨詢標(biāo)準(zhǔn)合同書
- 2025年石家莊道路貨物運(yùn)輸駕駛員考試
- 2025年福州從業(yè)資格證模擬考試題貨運(yùn)考題
- 廚房清潔記錄表范本模板
- 互聯(lián)網(wǎng)金融(同濟(jì)大學(xué))智慧樹知到答案章節(jié)測(cè)試2023年
- 水泥穩(wěn)定碎石基層施工方案完整版
- 超高大截面框架柱成型質(zhì)量控制
- 氣體滅火系統(tǒng)培訓(xùn)2
- GB/T 38228-2019呼吸防護(hù)自給閉路式氧氣逃生呼吸器
- 第十三章政府債務(wù)(政府經(jīng)濟(jì)學(xué)-山東大學(xué),陳東)
- PES11080Jan2019車用材料及零部件散發(fā)性能測(cè)試標(biāo)準(zhǔn)及要求
- 濃密機(jī)安裝施工方案
- 皇帝的新裝英語話劇劇本
- 2022版義務(wù)教育(道德與法治)課程標(biāo)準(zhǔn)(含2022年修訂部分)
評(píng)論
0/150
提交評(píng)論