C+實(shí)現(xiàn)簡(jiǎn)單的學(xué)生信息管理系統(tǒng)控制臺(tái)程序_第1頁(yè)
C+實(shí)現(xiàn)簡(jiǎn)單的學(xué)生信息管理系統(tǒng)控制臺(tái)程序_第2頁(yè)
C+實(shí)現(xiàn)簡(jiǎn)單的學(xué)生信息管理系統(tǒng)控制臺(tái)程序_第3頁(yè)
C+實(shí)現(xiàn)簡(jiǎn)單的學(xué)生信息管理系統(tǒng)控制臺(tái)程序_第4頁(yè)
C+實(shí)現(xiàn)簡(jiǎn)單的學(xué)生信息管理系統(tǒng)控制臺(tái)程序_第5頁(yè)
已閱讀5頁(yè),還剩22頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、/ #include "stdafx.h"#include <cstring>#include <iostream>#include <conio.h>#include<vector>#include<algorithm>class Studentprivate:char idNumber13; / 學(xué)號(hào)char name30; / 姓名char address50; / 地址char telephone14; / 號(hào)int gradeMath; /數(shù)學(xué)成績(jī)int gradePhysics; /物理成績(jī)int gr

2、adeEnglish; /英語(yǔ)成績(jī)double gradeMaPhEgAverage; /物數(shù)外平均int rankGrade; /成績(jī)排名int gradeClassmate; / 同學(xué)評(píng)分int gradeTeacher; /老師評(píng)分int gradeEthic; / 道德評(píng)分double gradeAll; /綜合成績(jī)int rankAll; /綜合排名public: Student(); /默認(rèn)構(gòu)造函數(shù)void Student_WritePersonalInformation(char *iD, char *nam, char *add, char *tel); /更改學(xué)生信息void

3、 Student_WriteMaPhEgGrade(int graMa, int graPh, int graEg); /更改學(xué)生測(cè)試成績(jī)void Student_WriteOtherGrade(int graCl, int graTe, int graEth); /更改學(xué)生其他成績(jī)void Student_DisplayInformation(); /顯示學(xué)生信息char *Student_ReadID();double Student_ReadGrade(); double Student_ReadTotalGrade(); int Student_ReadGradeRank(); int

4、 Student_ReadTotalGradeRank();void Student_WriteGradeRank(int ranGr); /更改學(xué)生成績(jī)排名void Student_WriteTotalGradeRank(int ranAl); /更改學(xué)生綜合排名char *Student_ReadName();Student:Student() /默認(rèn)構(gòu)造函數(shù) strncpy_s(idNumber, "000000000000",12); strncpy_s(name,"空",30); strncpy_s(address," 空"

5、,50); strncpy_s(telephone," 空",14); / 號(hào)gradeMath=0; /數(shù)學(xué)成績(jī)gradePhysics=0; /物理成績(jī)gradeEnglish=0; /英語(yǔ)成績(jī)gradeMaPhEgAverage=0; / 物數(shù)外平均rankGrade=0; /成績(jī)排名gradeClassmate=0; / 同學(xué)評(píng)分gradeTeacher=0; /老師評(píng)分gradeEthic=0; /道德評(píng)分gradeAll=0; /綜合成績(jī)r(jià)ankAll=0; / 綜合排名 void Student:Student_WritePersonalInformation

6、(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);void Student:Student_WriteMaPhEgGrade(int graMa, int graPh, int graEg)gradeMath = graMa;gradePhysics = graPh;gradeEnglish = graEg;gradeMaPhEgAverage

7、= (gradeMath + gradePhysics + gradeEnglish) / 3;void Student:Student_WriteOtherGrade(int graCl, int graTe, int graEth) gradeClassmate = graCl;gradeTeacher = graTe;gradeEthic = graEth;gradeAll = gradeMaPhEgAverage*0.6 + gradeClassmate*0.1 + gradeEthic*0.1 + gradeTeacher*0.2;)void Student:Student_Writ

8、eGradeRank(int ranGr)rankGrade = ranGr;)void Student:Student_WriteTotalGradeRank(int ranAl)rankAll = ranAl;)void Student:Student_DisplayInformation()using namespace std;cout << "" << endl;cout << "學(xué)生信息"<< endl;cout << " 姓名:"<< name &l

9、t;< endl<< "學(xué)號(hào):"<< idNumber << endl<< "地址:"<< address << endl<< " :"<< telephone << endl< < " 數(shù)學(xué)成績(jī):"<< gradeMath << endl< < "物理成績(jī):"<< gradePhysics << endl<

10、; < "英語(yǔ)成績(jī):"<< gradeEnglish << endl< < "三科平均成績(jī):"<< gradeMaPhEgAverage << endl< < "學(xué)習(xí)成績(jī)排名:"<< rankGrade << endl< < "同學(xué)評(píng)價(jià)得分:"<< gradeClassmate << endl< < "教師評(píng)價(jià)得分:"<< gradeT

11、eacher << endl< < "道德修養(yǎng)評(píng)分:"<< gradeEthic << endl< < "綜合成績(jī):"<< gradeAll << endl< < "綜合成績(jī)排名:"<< rankAll << endl;cout << "" << endl;char *Student:Student_ReadID()return idNumber;double Studen

12、t:Student_ReadGrade()return gradeMaPhEgAverage; double Student:Student_ReadTotalGrade()return gradeAll;)int Student:Student_ReadGradeRank()(return rankGrade;)int Student:Student_ReadTotalGradeRank()(return rankAll;)namespace studentInformation(std:vector<Student> studentVector;int flagStudentC

13、hoose=0;int flagStudentFound=1;)char *Student:Student_ReadName()(return name;)/ 以上是根本數(shù)據(jù)結(jié)構(gòu)的定義,同時(shí)定義了對(duì)數(shù)據(jù)的根本操作O定義完畢了,接下來(lái)是功能函數(shù) void MainMenu();void EditMenu();void AddStudentPersonalInformation(int mode);void ModifyStudentInformation();void SearchStudent();void DeleteStudentInformation();void DisplayStud

14、entInformation();void RankByGrade();void RankByTotalGrade();void RankByID();bool CmpGrade(Student student1,Student student2); / 這個(gè)函數(shù)的參數(shù)是兩個(gè)Student類的對(duì)象bool CmpTotalGrade(Student student1, Student student2);bool CmpID(Student student1, Student student2);void DisplayAllStudentInformation();/ 以 下 是 主 菜 單

15、 界 面 函 數(shù)-void MainMenu()int flagOperateInformation = 1;while (flagOperateInformation)using namespace std;cout << "" << endl;cout << "歡送進(jìn)入學(xué)生信息治理系統(tǒng)V1.0." << endl << endl;cout << "按下1:進(jìn)入學(xué)生信息治理系統(tǒng)."<< endl;cout << "按下 0:退出

16、."<< endl;cout <<""<<endl<<endl<<endl;cin >> flagOperateInformation;cin.clear();cout << endl;if (flagOperateInformation) EditMenu(); / 主 菜 單 界 面 函 數(shù) 定 義 完 畢/ 以 下 是 編 輯 界 面 函 數(shù)void EditMenu()int flagContinueOperation = 1;while (flagContinueOper

17、ation)flagContinueOperation = 0;using namespace std;cout << "" << endl;cout << " 主菜單 "<< endl;cout << "按下1:添加學(xué)生信息."<< endl;cout << "按下2:修改學(xué)生信息."<< endl;cout << "按下3:刪除學(xué)生信息."<< endl;cout <

18、< "按下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í)."&

19、lt;< endl;cout << "" << endl << endl;cin >> flagContinueOperation;cin.clear();cout << endl;switch (flagContinueOperation)case 1:AddStudentPersonalInformation(1); break;case 2:ModifyStudentInformation(); break;case 3:DeleteStudentInformation(); break;case 4:

20、DisplayStudentInformation(); break;case 5:RankByID(); break;case 6:cout << "功能暫未實(shí)現(xiàn)"<< endl; break;case 7:cout << "功能暫未實(shí)現(xiàn) "<< endl; break;case 8:DisplayAllStudentInformation(); break;case 0:break;)/ 以 下 是 添 加 信 息 的 界 面void AddStudentPersonalInformation(int

21、mode)(using namespace std;int flagAddPersonalInformation;int flagAddGrade;int falgAddOtherGrade;Student student1;studentInformation:studentVector.push_back(student1);int currentObjectPosition;if (mode = 1)currentObjectPosition = studentInformation:studentVector.size() - 1;elsecurrentObjectPosition =

22、 studentInformation:flagStudentChoose;/<< endl;cout << "請(qǐng)依次添加根本信息、學(xué)習(xí)成績(jī)和其他成績(jī),且不要使用空格cout << "" << endl;cout << "根本信息"<< endl;cout << "按下1:錄入學(xué)生根本信息;"<< endl<< "按下0:跳過根本信息."<<endl<<""

23、;<<endl;cin >> flagAddPersonalInformation;cin.clear();if (flagAddPersonalInformation)char name30;char iD13;char address50;char phone14;cout << "請(qǐng)輸入學(xué)生姓名:"cin >> name;cin.clear();cout << "請(qǐng)輸入學(xué)生學(xué)號(hào):"cin >> iD;cin.clear();cout << "請(qǐng)輸入學(xué)生地址

24、:"cin >> address;cin.clear();cout << "請(qǐng)輸入學(xué)生 :"cin.clear();studentInformation:studentVectorcurrentObjectPosition.Student_WritePerso nalInformation(iD,name,address,phone);cout << "根本信息輸入成功!" << endl<< ""<< endl;/cout << "

25、;" << endl;cout << " 學(xué)習(xí)成績(jī) "<< endl;cout << "按下1:錄入學(xué)生學(xué)習(xí)成績(jī);"<< endl< < "按下0:跳過學(xué)習(xí)成績(jī)信息."<< endl< < ""<< endl;cin >> flagAddGrade;cin.clear();if (flagAddGrade)int mathGrade;int physicsGrade;int englis

26、hGrade;cout << "請(qǐng)輸入數(shù)學(xué)成績(jī):"cin >> mathGrade;cout << "請(qǐng)輸入物理成績(jī):II.cin >> physicsGrade;cin.clear();cout << "請(qǐng)輸入英語(yǔ)成績(jī):"cin >> englishGrade;cin.clear();studentInformation:studentVectorcurrentObjectPosition.Student_WriteMaPhE gGrade(mathGrade, phys

27、icsGrade, englishGrade);cout << "學(xué)習(xí)成績(jī)輸入成功!" << endl<< ""<< endl;/cout << "" << endl;cout << "其他成績(jī)"<< endl;cout << "按下1:錄入學(xué)生其他成績(jī);"<< endl< < "按下0:跳過其他成績(jī)信息."<< endl< &

28、lt; ""<< endl;cin >> flagAddGrade;cin.clear();if (flagAddGrade)int peerGrade;int teacherGrade;int ethicGrade;cout << "請(qǐng)輸入同學(xué)評(píng)議成績(jī):"cin >> peerGrade;cin.clear();cout << "請(qǐng)輸入教師評(píng)議成績(jī):"cin >> teacherGrade;cin.clear();cout << "請(qǐng)輸入道

29、德測(cè)評(píng)成績(jī)成績(jī):"cin >> ethicGrade;cin.clear();studentInformation:studentVectorcurrentObjectPosition.Student_WriteOther Grade(peerGrade, teacherGrade, ethicGrade);cout << "其他成績(jī)輸入成功!" << endl<< ""<< endl;RankByGrade();RankByTotalGrade();cout << &qu

30、ot;學(xué)生成績(jī)錄入成功!" << endl;cout << "" << endl<<endl;void SearchStudent()using namespace std;using namespace studentinformation;char ID13;cout << "請(qǐng)輸入學(xué)生的學(xué)號(hào):"<<endl;cin >> ID;cin.clear();cout << ""<<endl;int vectorSize

31、 = studentVector.size();int i = 0;while (i<vectorSize) & (flagStudentFound!=0)(flagStudentFound = strcmp(ID, studentVectori.Student_ReadID();i = i + 1;)if (flagStudentFound = 0)(flagStudentChoose = i - 1;flagStudentFound = 1;cout << "您所查找的學(xué)生信息如下:"<<endl;studentVectorflag

32、StudentChoose.Student_DisplayInformation();)else(cout << "未找到該學(xué)生"<< endl;)void ModifyStudentInformation()(using namespace std;using namespace studentInformation;int searchVectorSize = studentVector.size();if (searchVectorSize = 0)(<< endl;cout << "" <&l

33、t; endl;cout << "當(dāng)前系統(tǒng)中沒有學(xué)生信息,請(qǐng)先添加學(xué)生信息!cout << "" << endl;)else(SearchStudent();cout << "您想對(duì)該學(xué)生的信息進(jìn)行修改嗎?" << endl;cout << "按下 1:是的."<< endl;cout << "按下0:放棄修改."<< endl;cout << "" <<

34、 endl;int flagModify;cin >> flagModify;cin.clear();if (flagModify = 1)&(flagStudentFound = 0)AddStudentPersonalInformation(2);)void DeleteStudentInformation()(using namespace std;using namespace studentInformation;int deleteVectorSize = studentVector.size();if (deleteVectorSize = 0)(cout &

35、lt;< "" << endl;cout << "當(dāng)前系統(tǒng)中沒有學(xué)生信息,請(qǐng)先添加學(xué)生信息!" << endl;cout << "" << endl;)else(SearchStudent();cout << "您想刪除該學(xué)生的信息嗎?" << endl;cout << "按下 1:刪除."<< endl;cout << "按下 0:取消."<&

36、lt; endl;cout << "" << endl;int flagModify;cin >> flagModify;cin.clear();if (flagModify = 1)&(flagStudentFound = 0)(std:vector<Student>:iteratoriter = studentVector.begin()flagStudentChoose; 這樣就選中了一個(gè)查到的元素studentVector.erase(iter);cout << "學(xué)生信息刪除成功!&qu

37、ot; << endl<< ""<< endl;void DisplayStudentInformation()(using namespace std;using namespace studentInformation;int displayVectorSize = studentVector.size();if (displayVectorSize = 0)(cout << "" << endl;cout << "當(dāng)前系統(tǒng)中沒有學(xué)生信息,請(qǐng)先添加學(xué)生信息!"

38、 << endl;cout << "" << endl;elseSearchStudent();if (flagStudentFound = 0)studentVectorflagStudentChoose.Student_DisplayInformation();)bool CmpGrade(Student student1, Student student2)如果return student1.Student_ReadGrade() > student2.Student_ReadGrade(); /student1成績(jī)大于stu

39、dent2 ,那么返回1.這樣能實(shí)現(xiàn)成績(jī)的降序排列)void RankByGrade()using namespace studentInformation;using namespace std;int rankVectorSize = studentVector.size();if (rankVectorSize = 1)studentVector0.Student_WriteGradeRank(1);) elsesortsort(studentVector.begin(), studentVector.end(), CmpGrade); /使用必須加上#include algorithm

40、和std.sort的前兩個(gè)參數(shù)是指針int i = 0;for (i = 0; i <= rankVectorSize-1; i+) (if (i>=1)&&(studentVectori.Student_ReadGrade() = studentVectori1.Student_ReadGrade()studentVectori.Student_WriteGradeRank(studentVectori1.Student_ReadGradeRank();elsestudentVectori.Student_WriteGradeRank(i + 1);bool Cm

41、pTotalGrade(Student student1, Student student2)(return student1.Student_ReadTotalGrade() > student2.Student_ReadTotalGrade();/如果student1成績(jī)大于student2 ,那么返回1.這樣能實(shí)現(xiàn)成績(jī)的降序排列void RankByTotalGrade()(using namespace studentInformation;using namespace std;int rankVectorSize = studentVector.size();if (rank

42、VectorSize = 1)studentVector0.Student_WriteTotalGradeRank(1);) else (sortsort(studentVector.begin(), studentVector.end(), CmpGrade); /使用必須加上#include algorithm和std.sort的前兩個(gè)參數(shù)是指針int i = 0;for (i = 0; i <= rankVectorSize - 1; i+) (if (i>= 1)&& (studentVectori.Student_ReadTotalGrade()stude

43、ntVectori - 1.Student_ReadTotalGrade()studentVectori.Student_WriteTotalGradeRank(studentVectori1.Student_ReadTotalGradeRank();elsestudentVectori.Student_WriteTotalGradeRank(i + 1);)bool CmpID(Student student1, Student student2)(int result;result = strcmp(student1.Student_ReadID(), student2.Student_R

44、eadID();if (result<0)return true;elsereturn false;void RankByID()(using namespace studentInformation;using namespace std;int rankVectorSize = studentVector.size();sort(studentVector.begin(), studentVector.end(), CmpID);cout << "" << endl;cout << " 排序成功! " <

45、;< endl;cout << "" << endl;)void DisplayAllStudentInformation()(using namespace std;using namespace studentInformation;int displayVectorSize = studentVector.size();int i;if (displayVectorSize = 0)(cout << "" << endl;cout <<cout << "當(dāng)前系統(tǒng)

46、中沒有學(xué)生信息!" << endl;<< endl;else(cout << ""<<endl;cout << "姓名學(xué)號(hào)綜合成績(jī)綜合排名"<< endl;for (i = 0; i < displayVectorSize; i+)(cout << studentVectori.Student_ReadName() << ""< < studentVectori.Student_ReadID() <<

47、 ""< < studentVectori.Student_ReadTotalGrade()<<""< < studentVectori.Student_ReadTotalGradeRank() << endl;cout << ""<<endl;/ 以 下 是 主 函 數(shù)void main()(MainMenu();/*sort ()下面的這是一個(gè)排序函數(shù),用到了冒泡排序法,但是程序沒用到.上面的排序用了函數(shù)來(lái)實(shí)現(xiàn),功能是一樣的.*/*void RankByGra

48、de()(using namespace studentinformation;using namespace std;int flagCompareOut=0;int flagComparein=0;int rankVectorSize;rankVectorSize = studentVector.size();if (rankVectorSize = 0)(cout << "" << endl<< "系統(tǒng)當(dāng)前沒有學(xué)生信息!" << endl<< ""<< en

49、dl;)else if (rankVectorSize = 1)(studentVectorflagCompareOut.Student_WriteGradeRank(flagCompareOut + 1);)elseint flagCompareOut = 0;int flagCompareln = 0;for (flagCompareOut = 0; flagCompareOut < rankVectorSize - 1; flagCompareOut+)(for (flagCompareIn = 0; flagCompareIn < rankVectorSize - flagCompareOut - 1;flagCompareIn+)(if(studentVectorflagCompareIn.Student_ReadGrade()<studentVectorflagCompareIn + 1.Student_ReadGrade()(Student studen

溫馨提示

  • 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ù)覽,若沒有圖紙預(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ì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論