版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
C實(shí)現(xiàn)簡單的學(xué)生信息標(biāo)準(zhǔn)管理系統(tǒng)控制臺程序//:Definestheentrypointfortheconsoleapplication.//#include""#include<cstring>#include<iostream>#include<>#include<vector>#include<algorithm>classStudent{private:charidNumber[13];//學(xué)號 charname[30];//姓名 charaddress[50];//地址 chartelephone[14];//電話號碼 intgradeMath;//數(shù)學(xué)成績 intgradePhysics;//物理成績 intgradeEnglish;//英語成績 doublegradeMaPhEgAverage;//物數(shù)外平均 intrankGrade;//成績排名 intgradeClassmate;//同學(xué)評分 intgradeTeacher;//老師評分 intgradeEthic;//道德評分 doublegradeAll;//綜合成績 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é)生考試成績 voidStudent_WriteOtherGrade(intgraCl,intgraTe,intgraEth);//更改學(xué)生其他成績 voidStudent_DisplayInformation();//顯示學(xué)生信息 char*Student_ReadID(); doubleStudent_ReadGrade(); doubleStudent_ReadTotalGrade(); intStudent_ReadGradeRank(); intStudent_ReadTotalGradeRank(); voidStudent_WriteGradeRank(intranGr);//更改學(xué)生成績排名 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);//電話號碼 gradeMath=0;//數(shù)學(xué)成績 gradePhysics=0;//物理成績 gradeEnglish=0;//英語成績 gradeMaPhEgAverage=0;//物數(shù)外平均 rankGrade=0;//成績排名 gradeClassmate=0;//同學(xué)評分 gradeTeacher=0;//老師評分 gradeEthic=0;//道德評分gradeAll=0;//綜合成績 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é)號:"<<idNumber<<endl <<"地址:"<<address<<endl <<"電話:"<<telephone<<endl <<"數(shù)學(xué)成績:"<<gradeMath<<endl <<"物理成績:"<<gradePhysics<<endl <<"英語成績:"<<gradeEnglish<<endl <<"三科平均成績:"<<gradeMaPhEgAverage<<endl <<"學(xué)習(xí)成績排名:"<<rankGrade<<endl <<"同學(xué)評價得分:"<<gradeClassmate<<endl <<"教師評價得分:"<<gradeTeacher<<endl <<"道德修養(yǎng)評分:"<<gradeEthic<<endl <<"綜合成績:"<<gradeAll<<endl <<"綜合成績排名:"<<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ù)據(jù)的基本操作。定義完畢了,接下來是功能函數(shù)--------------------voidMainMenu();voidEditMenu();voidAddStudentPersonalInformation(intmode);voidModifyStudentInformation();voidSearchStudent();voidDeleteStudentInformation();voidDisplayStudentInformation();voidRankByGrade();voidRankByTotalGrade();voidRankByID();boolCmpGrade(Studentstudent1,Studentstudent2);//這個函數(shù)的參數(shù)是兩個Student類的對象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é)號升序排序"<<endl; cout<<"按下6:讀入已有信息(暫時沒實(shí)現(xiàn))"<<endl; cout<<"按下7:將信息輸出(暫時沒實(shí)現(xiàn))"<<endl; cout<<"按下8:顯示系統(tǒng)內(nèi)所有學(xué)生的信息"<<endl; cout<<"按下0:返回上一級."<<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<<"請依次添加基本信息、學(xué)習(xí)成績和其他成績,且不要使用空格"<<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<<"請輸入學(xué)生姓名:"; cin>>name; (); cout<<"請輸入學(xué)生學(xué)號:"; cin>>iD; (); cout<<"請輸入學(xué)生地址:"; cin>>address; (); cout<<"請輸入學(xué)生電話:"; cin>>phone; (); studentInformation::studentVector[currentObjectPosition].Student_WritePersonalInformation(iD,name,address,phone); cout<<"基本信息輸入成功!"<<endl <<"------------------------------"<<endl; } //------------------------------------------------------------------------------------ cout<<"-------------------------------------"<<endl; cout<<"學(xué)習(xí)成績"<<endl; cout<<"按下1:錄入學(xué)生學(xué)習(xí)成績;"<<endl <<"按下0:跳過學(xué)習(xí)成績信息。"<<endl <<"--------------------------------------"<<endl; cin>>flagAddGrade; (); if(flagAddGrade) { intmathGrade; intphysicsGrade; intenglishGrade; cout<<"請輸入數(shù)學(xué)成績:"; cin>>mathGrade; (); cout<<"請輸入物理成績:"; cin>>physicsGrade; (); cout<<"請輸入英語成績:"; cin>>englishGrade; (); studentInformation::studentVector[currentObjectPosition].Student_WriteMaPhEgGrade(mathGrade,physicsGrade,englishGrade); cout<<"學(xué)習(xí)成績輸入成功!"<<endl <<"------------------------------"<<endl; } //--------------------------------------------------------------- cout<<"-------------------------------------"<<endl; cout<<"其他成績"<<endl; cout<<"按下1:錄入學(xué)生其他成績;"<<endl <<"按下0:跳過其他成績信息。"<<endl <<"--------------------------------------"<<endl; cin>>flagAddGrade; (); if(flagAddGrade) { intpeerGrade; intteacherGrade; intethicGrade; cout<<"請輸入同學(xué)評議成績:"; cin>>peerGrade; (); cout<<"請輸入教師評議成績:"; cin>>teacherGrade; (); cout<<"請輸入道德測評成績成績:"; cin>>ethicGrade; (); studentInformation::studentVector[currentObjectPosition].Student_WriteOtherGrade(peerGrade,teacherGrade,ethicGrade); cout<<"其他成績輸入成功!"<<endl <<"------------------------------"<<endl; } RankByGrade(); RankByTotalGrade(); cout<<"學(xué)生成績錄入成功!"<<endl; cout<<"-------------------------------------"<<endl<<endl;}voidSearchStudent(){ usingnamespacestd; usingnamespacestudentInformation; charID[13]; cout<<"請輸入學(xué)生的學(xué)號:"<<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é)生信息,請先添加學(xué)生信息!"<<endl; cout<<"---------------------------------------"<<endl; } else { SearchStudent(); cout<<"您想對該學(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é)生信息,請先添加學(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;//這樣就選中了一個查到的元素 (iter); } cout<<"學(xué)生信息刪除成功!"<<endl <<"----------------------------------"<<endl; }}voidDisplayStudentInformation(){ usingnamespacestd; usingnamespacestudentInformation; intdisplayVectorSize=(); if(displayVectorSize==0) { cout<<"---------------------------------------"<<endl; cout<<"當(dāng)前系統(tǒng)中沒有學(xué)生信息,請先添加學(xué)生信息!"<<endl; cout<<"---------------------------------------"<<endl; } else { SearchStudent(); if(flagStudentFound==0) studentVector[flagStudentChoose].Student_DisplayInformation(); }}boolCmpGrade(Studentstudent1,Studentstudent2){ return()>();//如果student1成績大于student2,}voidRankByGrade(){ usingnamespacestudentInformation; usingnamespacestd; intrankVectorSize=(); if(rankVectorSize==1) { studentVector[0].Student_WriteGradeRank(1); } else { sort((),(),CmpGrade);//使用sort必須加上#includealgorithm和std。sort的前兩個參數(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成績大于student2,}voidRankByTotalGrade(){ usingnamespacestudentInformation; usingnamespacestd; intrankVectorSize=(); if(rankVectorSize==1) { studentVector[0].Student_WriteTotalGradeRank(1); } else { sort((),(),CmpGrade);//使用sort必須加上#includealgorithm和std。sort的前兩個參數(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é)號綜合成績綜合排名"<<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();}/*----------------------------------------------------------------------------------------下面的這是一個排序函數(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等.壓縮文件請下載最新的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)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024年版的軟件購買與技術(shù)支持合同
- 服裝銷售店長下半年工作計(jì)劃10篇
- 春季工作計(jì)劃模板8篇
- 2025年度全球十大風(fēng)險報告
- 創(chuàng)建文明城市倡議書范文合集九篇
- 員工辭職申請書匯編6篇
- 2025年高模量玻璃纖維布項(xiàng)目發(fā)展計(jì)劃
- 新安江生態(tài)補(bǔ)償報告
- 煤業(yè)企業(yè)調(diào)度室管理制度匯編
- 計(jì)劃生育-婦產(chǎn)科教學(xué)課件
- 建筑工地塔吊智能化發(fā)展趨勢分析
- 電梯年終工作總結(jié)2篇
- 導(dǎo)醫(yī)接待工作的常見問題與應(yīng)對策略
- 《客戶的分級》課件
- 信息技術(shù)與小學(xué)語文閱讀教學(xué)深度融合的策略研究
- 大連市船舶運(yùn)輸與經(jīng)濟(jì)發(fā)展的市場研究報告
- GB/T 2881-2023工業(yè)硅
- DB3302T 1156-2023 水利水務(wù)設(shè)施基礎(chǔ)感知點(diǎn)位設(shè)置規(guī)范
- 內(nèi)科醫(yī)生的醫(yī)患關(guān)系與患者滿意度
- 小學(xué)生低年級語文閱讀能力評價標(biāo)準(zhǔn)及評價辦法
- 案例:伊通河中段水環(huán)境綜合整治工程
評論
0/150
提交評論