版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、/ StudentInformationSystem.cpp : Defines the entry point for the console application./#include "stdafx.h"#include <cstring>#include <iostream>#include <conio.h>#include<vector>#include<algorithm>class Studentprivate: char idNumber13; /學(xué)號(hào)char name30; /姓名char ad
2、dress50; /地址char telephone14; /電話號(hào)碼int gradeMath; /數(shù)學(xué)成績(jī)int gradePhysics; /物理成績(jī)int gradeEnglish; /英語成績(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
3、_WritePersonalInformation(char *iD, char *nam, char *add, char *tel); /更改學(xué)生信息void Student_WriteMaPhEgGrade(int graMa, int graPh, int graEg); /更改學(xué)生考試成績(jī)void Student_WriteOtherGrade(int graCl, int graTe, int graEth); /更改學(xué)生其他成績(jī)void Student_DisplayInformation(); /顯示學(xué)生信息char *Student_ReadID();double Stude
4、nt_ReadGrade();double Student_ReadTotalGrade();int Student_ReadGradeRank();int 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&
5、quot;,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)分 gra
6、deAll=0; /綜合成績(jī)r(jià)ankAll=0; /綜合排名 void Student: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);void Student:Student_WriteMaPhEgGrade(int graMa, int graPh, int graEg)gra
7、deMath = graMa;gradePhysics = graPh;gradeEnglish = graEg;gradeMaPhEgAverage = (gradeMath + gradePhysics + gradeEnglish) / 3;void Student:Student_WriteOtherGrade(int graCl, int graTe, int graEth)gradeClassmate = graCl;gradeTeacher = graTe;gradeEthic = graEth;gradeAll = gradeMaPhEgAverage*0.6 + gradeC
8、lassmate*0.1 + gradeEthic*0.1 + gradeTeacher*0.2;void Student:Student_WriteGradeRank(int ranGr)rankGrade = ranGr;void Student:Student_WriteTotalGradeRank(int ranAl)rankAll = ranAl;void Student:Student_DisplayInformation()using namespace std;cout << "-" << endl;cout << &qu
9、ot; 學(xué)生信息 " << endl;cout << "姓名:" << name << endl<< "學(xué)號(hào):" << idNumber << endl<< "地址:" << address << endl<< "電話:" << telephone << endl << "數(shù)學(xué)成績(jī):" << gradeMat
10、h << endl<< "物理成績(jī):" << gradePhysics << endl<< "英語成績(jī):" << gradeEnglish << endl<< "三科平均成績(jī):" << gradeMaPhEgAverage << endl<< "學(xué)習(xí)成績(jī)排名:" << rankGrade << endl<< "同學(xué)評(píng)價(jià)得分:" &
11、lt;< gradeClassmate << endl<< "教師評(píng)價(jià)得分:" << gradeTeacher << endl<< "道德修養(yǎng)評(píng)分:" << gradeEthic << endl<< "綜合成績(jī):" << gradeAll << endl<< "綜合成績(jī)排名:" << rankAll << endl;cout << "
12、-" << endl;char *Student:Student_ReadID()return idNumber;double Student:Student_ReadGrade()return gradeMaPhEgAverage;double Student:Student_ReadTotalGrade()return gradeAll;int Student:Student_ReadGradeRank()return rankGrade;int Student:Student_ReadTotalGradeRank()return rankAll;namespace
13、studentInformationstd:vector<Student> studentVector;int flagStudentChoose=0;int flagStudentFound=1;char *Student:Student_ReadName()return name;/-以上是基本數(shù)據(jù)結(jié)構(gòu)的定義,同時(shí)定義了對(duì)數(shù)據(jù)的基本操作。定義完畢了,接下來是功能函數(shù)-void MainMenu();void EditMenu();void AddStudentPersonalInformation(int mode);void ModifyStudentInformation(
14、);void SearchStudent();void DeleteStudentInformation();void DisplayStudentInformation();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 student
15、1, Student student2);void DisplayAllStudentInformation();/-以下是主菜單界面函數(shù)-void MainMenu()int flagOperateInformation = 1;while (flagOperateInformation)using namespace std;cout << "-" << endl;cout << "歡迎進(jìn)入學(xué)生信息管理系統(tǒng)V1.0." << endl << endl;cout << "
16、按下1:進(jìn)入學(xué)生信息管理系統(tǒng)." << endl;cout << "按下0:退出." << endl;cout << "-" << endl<<endl<<endl;cin >> flagOperateInformation;cin.clear();cout << endl;if (flagOperateInformation)EditMenu();/-主菜單界面函數(shù)定義完畢-/-以下是編輯界面函數(shù)-void EditMenu()int
17、flagContinueOperation = 1;while (flagContinueOperation)flagContinueOperation = 0;using namespace std;cout << "-" << endl;cout << " 主菜單 " << endl;cout << "按下1:添加學(xué)生信息." << endl;cout << "按下2:修改學(xué)生信息." << endl;cout &l
18、t;< "按下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é)生的信息
19、" << endl;cout << "按下0:返回上一級(jí)." << endl;cout << "-" << endl << endl;cin >> flagContinueOperation;cin.clear();cout << endl;switch (flagContinueOperation) case 1:AddStudentPersonalInformation(1); break;case 2:ModifyStudentInformat
20、ion(); break;case 3:DeleteStudentInformation(); break;case 4: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:brea
21、k;/-/-以下是添加信息的界面-void AddStudentPersonalInformation(int mode)using namespace std;int flagAddPersonalInformation;int flagAddGrade;int falgAddOtherGrade;Student student1;studentInformation:studentVector.push_back(student1);int currentObjectPosition;if (mode = 1)currentObjectPosition = studentInformati
22、on:studentVector.size() - 1;elsecurrentObjectPosition = studentInformation:flagStudentChoose;/-cout << "請(qǐng)依次添加基本信息、學(xué)習(xí)成績(jī)和其他成績(jī),且不要使用空格" << endl;cout << "-" << endl;cout << " 基本信息 " << endl;cout << "按下1:錄入學(xué)生基本信息;" <<
23、 endl<< "按下0:跳過基本信息。"<<endl<<"-"<<endl;cin >> flagAddPersonalInformation;cin.clear();if (flagAddPersonalInformation)char name30;char iD13;char address50;char phone14;cout << "請(qǐng)輸入學(xué)生姓名:"cin >> name;cin.clear();cout << "
24、請(qǐng)輸入學(xué)生學(xué)號(hào):"cin >> iD;cin.clear();cout << "請(qǐng)輸入學(xué)生地址:"cin >> address;cin.clear();cout << "請(qǐng)輸入學(xué)生電話:"cin >> phone;cin.clear();studentInformation:studentVectorcurrentObjectPosition.Student_WritePersonalInformation(iD,name,address,phone);cout << &q
25、uot;基本信息輸入成功!" << endl<< "-" << endl;/-cout << "-" << endl;cout << " 學(xué)習(xí)成績(jī) " << endl;cout << "按下1:錄入學(xué)生學(xué)習(xí)成績(jī);" << endl<< "按下0:跳過學(xué)習(xí)成績(jī)信息。" << endl<< "-" << endl;c
26、in >> flagAddGrade;cin.clear();if (flagAddGrade)int mathGrade;int physicsGrade;int englishGrade;cout << "請(qǐng)輸入數(shù)學(xué)成績(jī):"cin >> mathGrade;cin.clear();cout << "請(qǐng)輸入物理成績(jī):"cin >> physicsGrade;cin.clear();cout << "請(qǐng)輸入英語成績(jī):"cin >> englishGra
27、de;cin.clear();studentInformation:studentVectorcurrentObjectPosition.Student_WriteMaPhEgGrade(mathGrade, physicsGrade, englishGrade);cout << "學(xué)習(xí)成績(jī)輸入成功!" << endl<< "-" << endl;/-cout << "-" << endl;cout << " 其他成績(jī) " <
28、< endl;cout << "按下1:錄入學(xué)生其他成績(jī);" << endl<< "按下0:跳過其他成績(jī)信息。" << endl<< "-" << endl;cin >> flagAddGrade;cin.clear();if (flagAddGrade)int peerGrade;int teacherGrade;int ethicGrade;cout << "請(qǐng)輸入同學(xué)評(píng)議成績(jī):"cin >> pe
29、erGrade;cin.clear();cout << "請(qǐng)輸入教師評(píng)議成績(jī):"cin >> teacherGrade;cin.clear();cout << "請(qǐng)輸入道德測(cè)評(píng)成績(jī)成績(jī):"cin >> ethicGrade;cin.clear();studentInformation:studentVectorcurrentObjectPosition.Student_WriteOtherGrade(peerGrade, teacherGrade, ethicGrade);cout << &qu
30、ot;其他成績(jī)輸入成功!" << endl<< "-" << endl;RankByGrade();RankByTotalGrade();cout << "學(xué)生成績(jī)錄入成功!" << endl;cout << "-" << endl<<endl;void SearchStudent()using namespace std;using namespace studentInformation;char ID13;cout <
31、< "請(qǐng)輸入學(xué)生的學(xué)號(hào):"<<endl;cin >> ID;cin.clear();cout << "-"<<endl;int vectorSize = studentVector.size();int i = 0;while (i<vectorSize) & (flagStudentFound!=0)flagStudentFound = strcmp(ID, studentVectori.Student_ReadID();i = i + 1;if (flagStudentFound =
32、 0)flagStudentChoose = i - 1;flagStudentFound = 1;cout << "您所查找的學(xué)生信息如下:"<<endl;studentVectorflagStudentChoose.Student_DisplayInformation();elsecout << "未找到該學(xué)生" << endl;void ModifyStudentInformation()using namespace std;using namespace studentInformation;in
33、t searchVectorSize = studentVector.size();if (searchVectorSize = 0)cout << "-" << endl;cout << "當(dāng)前系統(tǒng)中沒有學(xué)生信息,請(qǐng)先添加學(xué)生信息!" << endl;cout << "-" << endl;elseSearchStudent(); cout << "您想對(duì)該學(xué)生的信息進(jìn)行修改嗎?" << endl;cout <&
34、lt; "按下1:是的。" << endl;cout << "按下0:放棄修改。" << endl;cout << "-" << endl;int flagModify;cin >> flagModify;cin.clear();if (flagModify = 1)&(flagStudentFound = 0)AddStudentPersonalInformation(2);void DeleteStudentInformation()using nam
35、espace std;using namespace studentInformation;int deleteVectorSize = studentVector.size();if (deleteVectorSize = 0)cout << "-" << endl;cout << "當(dāng)前系統(tǒng)中沒有學(xué)生信息,請(qǐng)先添加學(xué)生信息!" << endl;cout << "-" << endl;elseSearchStudent();cout << "
36、;您想刪除該學(xué)生的信息嗎?" << endl;cout << "按下1:刪除。" << endl;cout << "按下0:取消。" << endl;cout << "-" << endl;int flagModify;cin >> flagModify;cin.clear();if (flagModify = 1)&(flagStudentFound = 0)std:vector<Student>:itera
37、tor iter = studentVector.begin() + flagStudentChoose; /這樣就選中了一個(gè)查到的元素studentVector.erase(iter);cout << "學(xué)生信息刪除成功!" << endl<< "-" << endl;void DisplayStudentInformation()using namespace std;using namespace studentInformation;int displayVectorSize = studentVe
38、ctor.size();if (displayVectorSize = 0)cout << "-" << endl;cout << "當(dāng)前系統(tǒng)中沒有學(xué)生信息,請(qǐng)先添加學(xué)生信息!" << endl;cout << "-" << endl;elseSearchStudent();if (flagStudentFound = 0)studentVectorflagStudentChoose.Student_DisplayInformation();bool CmpGra
39、de(Student student1, Student student2)return student1.Student_ReadGrade() > student2.Student_ReadGrade(); /如果student1成績(jī)大于student2,則返回1.這樣能實(shí)現(xiàn)成績(jī)的降序排列void RankByGrade()using namespace studentInformation;using namespace std;int rankVectorSize = studentVector.size();if (rankVectorSize = 1)studentVecto
40、r0.Student_WriteGradeRank(1);elsesort(studentVector.begin(), studentVector.end(), CmpGrade); /使用sort必須加上#include algorithm和std。sort的前兩個(gè)參數(shù)是指針int i = 0;for (i = 0; i <= rankVectorSize-1; i+)if (i>=1)&&(studentVectori.Student_ReadGrade() = studentVectori - 1.Student_ReadGrade()studentVect
41、ori.Student_WriteGradeRank(studentVectori - 1.Student_ReadGradeRank();elsestudentVectori.Student_WriteGradeRank(i + 1);bool CmpTotalGrade(Student student1, Student student2)return student1.Student_ReadTotalGrade() > student2.Student_ReadTotalGrade(); /如果student1成績(jī)大于student2,則返回1.這樣能實(shí)現(xiàn)成績(jī)的降序排列void
42、RankByTotalGrade()using namespace studentInformation;using namespace std;int rankVectorSize = studentVector.size();if (rankVectorSize = 1)studentVector0.Student_WriteTotalGradeRank(1);elsesort(studentVector.begin(), studentVector.end(), CmpGrade); /使用sort必須加上#include algorithm和std。sort的前兩個(gè)參數(shù)是指針int i
43、 = 0;for (i = 0; i <= rankVectorSize - 1; i+)if (i >= 1) && (studentVectori.Student_ReadTotalGrade() = studentVectori - 1.Student_ReadTotalGrade()studentVectori.Student_WriteTotalGradeRank(studentVectori - 1.Student_ReadTotalGradeRank();elsestudentVectori.Student_WriteTotalGradeRank(i
44、+ 1);bool CmpID(Student student1, Student student2)int result;result = strcmp(student1.Student_ReadID(), student2.Student_ReadID();if (result<0)return true;elsereturn false;void RankByID()using namespace studentInformation;using namespace std;int rankVectorSize = studentVector.size();sort(student
45、Vector.begin(), studentVector.end(), CmpID);cout << "-" << endl;cout << "排序成功!" << endl;cout << "-" << endl;void DisplayAllStudentInformation()using namespace std;using namespace studentInformation;int displayVectorSize = studentVecto
46、r.size();int i;if (displayVectorSize = 0)cout << "-" << endl;cout << "當(dāng)前系統(tǒng)中沒有學(xué)生信息!" << endl;cout << "-" << endl;elsecout << "-" << endl;cout << "姓名 學(xué)號(hào) 綜合成績(jī) 綜合排名" << endl;for (i = 0; i < d
47、isplayVectorSize; i+)cout << studentVectori.Student_ReadName() << " "<< studentVectori.Student_ReadID() << " "<< studentVectori.Student_ReadTotalGrade() << " "<< studentVectori.Student_ReadTotalGradeRank() << endl;cout <
48、;< "-" << endl;/-以下是主函數(shù)-void main()MainMenu();/*-下面的這是一個(gè)排序函數(shù),用到了冒泡排序法,但是程序沒用到。上面的排序用了sort()函數(shù)來實(shí)現(xiàn),功能是一樣的。*/*void RankByGrade()using namespace studentInformation;using namespace std;int flagCompareOut=0;int flagCompareIn=0;int rankVectorSize;rankVectorSize = studentVector.size();if
49、(rankVectorSize = 0)cout << "-" << endl<< "系統(tǒng)當(dāng)前沒有學(xué)生信息!" << endl<< "-" << endl;else if (rankVectorSize = 1)studentVectorflagCompareOut.Student_WriteGradeRank(flagCompareOut + 1);elseint flagCompareOut = 0;int flagCompareIn = 0;for (fla
50、gCompareOut = 0; flagCompareOut < rankVectorSize - 1; flagCompareOut+)for (flagCompareIn = 0; flagCompareIn < rankVectorSize - flagCompareOut - 1; flagCompareIn+)if (studentVectorflagCompareIn.Student_ReadGrade() < studentVectorflagCompareIn + 1.Student_ReadGrade()Student studentTemp;studentTe
溫馨提示
- 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 宗教場(chǎng)所花崗巖裝修合同
- 資產(chǎn)管理企業(yè)會(huì)計(jì)崗位合同
- 戶外用品公司高管聘用合同樣本
- 二零二五年度個(gè)人小額貸款合同與信用風(fēng)險(xiǎn)防控3篇
- 2025版航空航天領(lǐng)域工程設(shè)計(jì)院勞務(wù)合作框架合同3篇
- 2024燃?xì)夤こ添?xiàng)目前期策劃與投資咨詢委托合同3篇
- 2024年物業(yè)維修合同補(bǔ)充條款
- 二零二五年度專業(yè)醫(yī)療設(shè)備研發(fā)與轉(zhuǎn)讓合同2篇
- 2024年簡(jiǎn)明日文個(gè)人借款合同模板版B版
- 2024年礦山運(yùn)輸設(shè)備租賃協(xié)議標(biāo)準(zhǔn)格式示例版
- 電力電子技術(shù)(廣東工業(yè)大學(xué))智慧樹知到期末考試答案章節(jié)答案2024年廣東工業(yè)大學(xué)
- 醫(yī)療器械經(jīng)營(yíng)質(zhì)量管理體系文件(全套)
- 富氫水項(xiàng)目經(jīng)濟(jì)效益及投資價(jià)值分析(模板參考)
- 小流域水土保持綜合治理工程初步設(shè)計(jì)
- 增強(qiáng)熱塑性塑料復(fù)合管在我國(guó)的發(fā)展現(xiàn)狀
- 機(jī)械設(shè)計(jì)外文文獻(xiàn)翻譯、中英文翻譯、外文翻譯
- 美標(biāo)漸開線花鍵計(jì)算程序2014.8
- 英格索蘭空壓機(jī)操作規(guī)程
- 風(fēng)動(dòng)送樣手冊(cè)
- 績(jī)效考核評(píng)分標(biāo)準(zhǔn)
- 電力建設(shè)施工技術(shù)管理
評(píng)論
0/150
提交評(píng)論