版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
C实现简单的学生信息标准管理系统控制台程序//:Definestheentrypointfortheconsoleapplication.//#include""#include<cstring>#include<iostream>#include<>#include<vector>#include<algorithm>classStudent{private:charidNumber[13];//学号 charname[30];//姓名 charaddress[50];//地址 chartelephone[14];//电话号码 intgradeMath;//数学成绩 intgradePhysics;//物理成绩 intgradeEnglish;//英语成绩 doublegradeMaPhEgAverage;//物数外平均 intrankGrade;//成绩排名 intgradeClassmate;//同学评分 intgradeTeacher;//老师评分 intgradeEthic;//道德评分 doublegradeAll;//综合成绩 intrankAll;//综合排名public: Student();//默认构造函数 voidStudent_WritePersonalInformation(char*iD,char*nam,char*add,char*tel);//更改学生信息 voidStudent_WriteMaPhEgGrade(intgraMa,intgraPh,intgraEg);//更改学生考试成绩 voidStudent_WriteOtherGrade(intgraCl,intgraTe,intgraEth);//更改学生其他成绩 voidStudent_DisplayInformation();//显示学生信息 char*Student_ReadID(); doubleStudent_ReadGrade(); doubleStudent_ReadTotalGrade(); intStudent_ReadGradeRank(); intStudent_ReadTotalGradeRank(); voidStudent_WriteGradeRank(intranGr);//更改学生成绩排名 voidStudent_WriteTotalGradeRank(intranAl);//更改学生综合排名 char*Student_ReadName();};Student::Student()//默认构造函数{ strncpy_s(idNumber,"000000000000",12); strncpy_s(name,"空",30); strncpy_s(address,"空",50); strncpy_s(telephone,"空",14);//电话号码 gradeMath=0;//数学成绩 gradePhysics=0;//物理成绩 gradeEnglish=0;//英语成绩 gradeMaPhEgAverage=0;//物数外平均 rankGrade=0;//成绩排名 gradeClassmate=0;//同学评分 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<<"学生信息"<<endl; cout<<"姓名:"<<name<<endl <<"学号:"<<idNumber<<endl <<"地址:"<<address<<endl <<"电话:"<<telephone<<endl <<"数学成绩:"<<gradeMath<<endl <<"物理成绩:"<<gradePhysics<<endl <<"英语成绩:"<<gradeEnglish<<endl <<"三科平均成绩:"<<gradeMaPhEgAverage<<endl <<"学习成绩排名:"<<rankGrade<<endl <<"同学评价得分:"<<gradeClassmate<<endl <<"教师评价得分:"<<gradeTeacher<<endl <<"道德修养评分:"<<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;}//-----------------------以上是基本数据结构的定义,同时定义了对数据的基本操作。定义完毕了,接下来是功能函数--------------------voidMainMenu();voidEditMenu();voidAddStudentPersonalInformation(intmode);voidModifyStudentInformation();voidSearchStudent();voidDeleteStudentInformation();voidDisplayStudentInformation();voidRankByGrade();voidRankByTotalGrade();voidRankByID();boolCmpGrade(Studentstudent1,Studentstudent2);//这个函数的参数是两个Student类的对象boolCmpTotalGrade(Studentstudent1,Studentstudent2);boolCmpID(Studentstudent1,Studentstudent2);voidDisplayAllStudentInformation();//-----------------------以下是主菜单界面函数-------------------------------------------------------------------------------voidMainMenu(){ intflagOperateInformation=1; while(flagOperateInformation) { usingnamespacestd; cout<<"-----------------------------------------------------"<<endl; cout<<"."<<endl<<endl; cout<<"按下1:进入学生信息管理系统."<<endl; cout<<"按下0:退出."<<endl; cout<<"-----------------------------------------------------"<<endl<<endl<<endl; cin>>flagOperateInformation; (); cout<<endl; if(flagOperateInformation) EditMenu(); }}//------------------------主菜单界面函数定义完毕--------------------------------------------------------------------------//------------------------以下是编辑界面函数------------------------------------------------------------------------------voidEditMenu(){ intflagContinueOperation=1; while(flagContinueOperation) { flagContinueOperation=0; usingnamespacestd; cout<<"--------------------------------------------"<<endl; cout<<"主菜单"<<endl; cout<<"按下1:添加学生信息."<<endl; cout<<"按下2:修改学生信息."<<endl; cout<<"按下3:删除学生信息."<<endl; cout<<"按下4:显示学生信息."<<endl; cout<<"按下5:按学号升序排序"<<endl; cout<<"按下6:读入已有信息(暂时没实现)"<<endl; cout<<"按下7:将信息输出(暂时没实现)"<<endl; cout<<"按下8:显示系统内所有学生的信息"<<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<<"功能暂未实现"<<endl;break; case7:cout<<"功能暂未实现"<<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<<"请依次添加基本信息、学习成绩和其他成绩,且不要使用空格"<<endl; cout<<"-------------------------------------"<<endl; cout<<"基本信息"<<endl; cout<<"按下1:录入学生基本信息;"<<endl <<"按下0:跳过基本信息。"<<endl <<"--------------------------------------"<<endl; cin>>flagAddPersonalInformation; (); if(flagAddPersonalInformation) { charname[30]; chariD[13]; charaddress[50]; charphone[14]; cout<<"请输入学生姓名:"; cin>>name; (); cout<<"请输入学生学号:"; cin>>iD; (); cout<<"请输入学生地址:"; cin>>address; (); cout<<"请输入学生电话:"; cin>>phone; (); studentInformation::studentVector[currentObjectPosition].Student_WritePersonalInformation(iD,name,address,phone); cout<<"基本信息输入成功!"<<endl <<"------------------------------"<<endl; } //------------------------------------------------------------------------------------ cout<<"-------------------------------------"<<endl; cout<<"学习成绩"<<endl; cout<<"按下1:录入学生学习成绩;"<<endl <<"按下0:跳过学习成绩信息。"<<endl <<"--------------------------------------"<<endl; cin>>flagAddGrade; (); if(flagAddGrade) { intmathGrade; intphysicsGrade; intenglishGrade; cout<<"请输入数学成绩:"; cin>>mathGrade; (); cout<<"请输入物理成绩:"; cin>>physicsGrade; (); cout<<"请输入英语成绩:"; cin>>englishGrade; (); studentInformation::studentVector[currentObjectPosition].Student_WriteMaPhEgGrade(mathGrade,physicsGrade,englishGrade); cout<<"学习成绩输入成功!"<<endl <<"------------------------------"<<endl; } //--------------------------------------------------------------- cout<<"-------------------------------------"<<endl; cout<<"其他成绩"<<endl; cout<<"按下1:录入学生其他成绩;"<<endl <<"按下0:跳过其他成绩信息。"<<endl <<"--------------------------------------"<<endl; cin>>flagAddGrade; (); if(flagAddGrade) { intpeerGrade; intteacherGrade; intethicGrade; cout<<"请输入同学评议成绩:"; cin>>peerGrade; (); cout<<"请输入教师评议成绩:"; cin>>teacherGrade; (); cout<<"请输入道德测评成绩成绩:"; cin>>ethicGrade; (); studentInformation::studentVector[currentObjectPosition].Student_WriteOtherGrade(peerGrade,teacherGrade,ethicGrade); cout<<"其他成绩输入成功!"<<endl <<"------------------------------"<<endl; } RankByGrade(); RankByTotalGrade(); cout<<"学生成绩录入成功!"<<endl; cout<<"-------------------------------------"<<endl<<endl;}voidSearchStudent(){ usingnamespacestd; usingnamespacestudentInformation; charID[13]; cout<<"请输入学生的学号:"<<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<<"您所查找的学生信息如下:"<<endl; studentVector[flagStudentChoose].Student_DisplayInformation(); } else { cout<<"未找到该学生"<<endl; }}voidModifyStudentInformation(){ usingnamespacestd; usingnamespacestudentInformation; intsearchVectorSize=(); if(searchVectorSize==0) { cout<<"---------------------------------------"<<endl; cout<<"当前系统中没有学生信息,请先添加学生信息!"<<endl; cout<<"---------------------------------------"<<endl; } else { SearchStudent(); cout<<"您想对该学生的信息进行修改吗?"<<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<<"当前系统中没有学生信息,请先添加学生信息!"<<endl; cout<<"---------------------------------------"<<endl; } else { SearchStudent(); cout<<"您想删除该学生的信息吗?"<<endl; cout<<"按下1:删除。"<<endl; cout<<"按下0:取消。"<<endl; cout<<"---------------------------------------"<<endl; intflagModify; cin>>flagModify; (); if((flagModify==1)&(flagStudentFound==0)) { std::vector<Student>::iteratoriter=()+flagStudentChoose;//这样就选中了一个查到的元素 (iter); } cout<<"学生信息删除成功!"<<endl <<"----------------------------------"<<endl; }}voidDisplayStudentInformation(){ usingnamespacestd; usingnamespacestudentInformation; intdisplayVectorSize=(); if(displayVectorSize==0) { cout<<"---------------------------------------"<<endl; cout<<"当前系统中没有学生信息,请先添加学生信息!"<<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的前两个参数是指针 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的前两个参数是指针 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<<"当前系统中没有学生信息!"<<endl; cout<<"------------------------"<<endl; } else { cout<<"--------------------------------------------------------"<<endl; cout<<"姓名学号综合成绩综合排名"<<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; }}//-----------------------以下是主函数-------------------------------------------------------------------------------------voidmain(){ MainMenu();}/*----------------------------------------------------------------------------------------下面的这是一个排序函数,用到了冒泡排序法,但是程序没用到。上面的排序用了sort()函数来实现,功能是一样的。*//*voidRankByGrade(){usingnamespacestudentInformation;usingnamespacestd;intflagCompareOut=0;intflagCompareIn=0;intrankVectorSize;rankVectorSize=();if(rankVectorSize==0){cout<<"---------------------------------"<<endl<<"系统当前没有学生信息!"<<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. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 重庆人文科技学院《基础护理学实训》2022-2023学年第一学期期末试卷
- 重庆人文科技学院《儿歌配奏与弹唱》2022-2023学年第一学期期末试卷
- 2024北京仁和中学七年级(上)期中数学(教师版)
- 重庆三峡学院《基础工程课程设计》2021-2022学年第一学期期末试卷
- 2024北京汇文中学八年级(上)期中数学(教师版)
- 重庆三峡学院《工程地质及土力学》2022-2023学年第一学期期末试卷
- 重庆三峡学院《风景区管理》2021-2022学年第一学期期末试卷
- 重庆人文科技学院《数据库》2022-2023学年期末试卷
- 重庆人文科技学院《美术》2021-2022学年第一学期期末试卷
- 重庆财经学院《网络技术基础》2021-2022学年期末试卷
- 学前教育大学生职业生涯规划
- 嵌入式职业规划
- 【曾国藩家庭教育思想对现代家庭教育的启示6900字(论文)】
- 教师的社会需求分析报告
- 睾丸鞘膜积液的护理查房
- 《病历书写基本规范》课件
- 《石墨简单介绍》课件
- 第三节创造有意义的人生
- 《非计划性拔管》课件
- 重大事故隐患排查表 21S
- DB11T 2189-2023防汛隐患排查治理规范 城镇内涝
评论
0/150
提交评论