欢迎来到淘文阁 - 分享文档赚钱的网站! | 帮助中心 好文档才是您的得力助手!
淘文阁 - 分享文档赚钱的网站
全部分类
  • 研究报告>
  • 管理文献>
  • 标准材料>
  • 技术资料>
  • 教育专区>
  • 应用文书>
  • 生活休闲>
  • 考试试题>
  • pptx模板>
  • 工商注册>
  • 期刊短文>
  • 图片设计>
  • ImageVerifierCode 换一换

    C++实现:简单的学生信息管理系统(控制台程序).doc

    • 资源ID:34136265       资源大小:75KB        全文页数:13页
    • 资源格式: DOC        下载积分:15金币
    快捷下载 游客一键下载
    会员登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录   QQ登录  
    二维码
    微信扫一扫登录
    下载资源需要15金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    C++实现:简单的学生信息管理系统(控制台程序).doc

    如有侵权,请联系网站删除,仅供学习与交流C+实现:简单的学生信息管理系统(控制台程序)【精品文档】第 13 页/ 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; /学号char name30; /姓名char address50; /地址char telephone14; /电话号码int gradeMath; /数学成绩int gradePhysics; /物理成绩int gradeEnglish; /英语成绩double gradeMaPhEgAverage; /物数外平均int rankGrade; /成绩排名int gradeClassmate; /同学评分int gradeTeacher; /老师评分int gradeEthic; /道德评分double gradeAll; /综合成绩int rankAll; /综合排名public:Student(); /默认构造函数void Student_WritePersonalInformation(char *iD, char *nam, char *add, char *tel); /更改学生信息void Student_WriteMaPhEgGrade(int graMa, int graPh, int graEg); /更改学生考试成绩void Student_WriteOtherGrade(int graCl, int graTe, int graEth); /更改学生其他成绩void Student_DisplayInformation(); /显示学生信息char *Student_ReadID();double Student_ReadGrade();double Student_ReadTotalGrade();int Student_ReadGradeRank();int Student_ReadTotalGradeRank();void Student_WriteGradeRank(int ranGr); /更改学生成绩排名void Student_WriteTotalGradeRank(int ranAl); /更改学生综合排名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; /综合排名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)gradeMath = 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 + gradeClassmate*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 << " 学生信息 " << 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()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 studentInformationstd:vector<Student> studentVector;int flagStudentChoose=0;int flagStudentFound=1;char *Student:Student_ReadName()return name;/-以上是基本数据结构的定义,同时定义了对数据的基本操作。定义完毕了,接下来是功能函数-void MainMenu();void EditMenu();void AddStudentPersonalInformation(int mode);void ModifyStudentInformation();void SearchStudent();void DeleteStudentInformation();void DisplayStudentInformation();void RankByGrade();void RankByTotalGrade();void RankByID();bool CmpGrade(Student student1,Student student2); /这个函数的参数是两个Student类的对象bool CmpTotalGrade(Student student1, Student student2);bool CmpID(Student student1, Student student2);void DisplayAllStudentInformation();/-以下是主菜单界面函数-void MainMenu()int flagOperateInformation = 1;while (flagOperateInformation)using namespace std;cout << "-" << endl;cout << "欢迎进入学生信息管理系统V1.0." << endl << endl;cout << "按下1:进入学生信息管理系统." << endl;cout << "按下0:退出." << endl;cout << "-" << endl<<endl<<endl;cin >> flagOperateInformation;cin.clear();cout << endl;if (flagOperateInformation)EditMenu();/-主菜单界面函数定义完毕-/-以下是编辑界面函数-void EditMenu()int flagContinueOperation = 1;while (flagContinueOperation)flagContinueOperation = 0;using namespace std;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;cin.clear();cout << endl;switch (flagContinueOperation) case 1:AddStudentPersonalInformation(1); break;case 2:ModifyStudentInformation(); break;case 3:DeleteStudentInformation(); break;case 4:DisplayStudentInformation(); break;case 5:RankByID(); break;case 6:cout << "功能暂未实现" << endl; break;case 7:cout << "功能暂未实现" << endl; break;case 8:DisplayAllStudentInformation(); break; case 0:break;/-以下是添加信息的界面-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 = studentInformation:studentVector.size() - 1;elsecurrentObjectPosition = studentInformation:flagStudentChoose;cout << "请依次添加基本信息、学习成绩和其他成绩,且不要使用空格" << endl;cout << "-" << endl;cout << " 基本信息 " << endl;cout << "按下1:录入学生基本信息;" << endl<< "按下0:跳过基本信息。"<<endl<<"-"<<endl;cin >> flagAddPersonalInformation;cin.clear();if (flagAddPersonalInformation)char name30;char iD13;char address50;char phone14;cout << "请输入学生姓名:"cin >> name;cin.clear();cout << "请输入学生学号:"cin >> iD;cin.clear();cout << "请输入学生地址:"cin >> address;cin.clear();cout << "请输入学生电话:"cin >> phone;cin.clear();studentInformation:studentVectorcurrentObjectPosition.Student_WritePersonalInformation(iD,name,address,phone);cout << "基本信息输入成功!" << endl<< "-" << endl;cout << "-" << endl;cout << " 学习成绩 " << endl;cout << "按下1:录入学生学习成绩;" << endl<< "按下0:跳过学习成绩信息。" << endl<< "-" << endl;cin >> flagAddGrade;cin.clear();if (flagAddGrade)int mathGrade;int physicsGrade;int englishGrade;cout << "请输入数学成绩:"cin >> mathGrade;cin.clear();cout << "请输入物理成绩:"cin >> physicsGrade;cin.clear();cout << "请输入英语成绩:"cin >> englishGrade;cin.clear();studentInformation:studentVectorcurrentObjectPosition.Student_WriteMaPhEgGrade(mathGrade, physicsGrade, englishGrade);cout << "学习成绩输入成功!" << endl<< "-" << endl;cout << "-" << endl;cout << " 其他成绩 " << endl;cout << "按下1:录入学生其他成绩;" << endl<< "按下0:跳过其他成绩信息。" << endl<< "-" << endl;cin >> flagAddGrade;cin.clear();if (flagAddGrade)int peerGrade;int teacherGrade;int ethicGrade;cout << "请输入同学评议成绩:"cin >> peerGrade;cin.clear();cout << "请输入教师评议成绩:"cin >> teacherGrade;cin.clear();cout << "请输入道德测评成绩成绩:"cin >> ethicGrade;cin.clear();studentInformation:studentVectorcurrentObjectPosition.Student_WriteOtherGrade(peerGrade, teacherGrade, ethicGrade);cout << "其他成绩输入成功!" << endl<< "-" << endl;RankByGrade();RankByTotalGrade();cout << "学生成绩录入成功!" << endl;cout << "-" << endl<<endl;void SearchStudent()using namespace std;using namespace studentInformation;char ID13;cout << "请输入学生的学号:"<<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 = 0)flagStudentChoose = i - 1;flagStudentFound = 1;cout << "您所查找的学生信息如下:"<<endl;studentVectorflagStudentChoose.Student_DisplayInformation();elsecout << "未找到该学生" << endl;void ModifyStudentInformation()using namespace std;using namespace studentInformation;int searchVectorSize = studentVector.size();if (searchVectorSize = 0)cout << "-" << endl;cout << "当前系统中没有学生信息,请先添加学生信息!" << endl;cout << "-" << endl;elseSearchStudent(); cout << "您想对该学生的信息进行修改吗?" << endl;cout << "按下1:是的。" << endl;cout << "按下0:放弃修改。" << endl;cout << "-" << 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 << "-" << endl;cout << "当前系统中没有学生信息,请先添加学生信息!" << endl;cout << "-" << endl;elseSearchStudent();cout << "您想删除该学生的信息吗?" << endl;cout << "按下1:删除。" << endl;cout << "按下0:取消。" << endl;cout << "-" << endl;int flagModify;cin >> flagModify;cin.clear();if (flagModify = 1)&(flagStudentFound = 0)std:vector<Student>:iterator iter = studentVector.begin() + flagStudentChoose; /这样就选中了一个查到的元素studentVector.erase(iter);cout << "学生信息删除成功!" << endl<< "-" << endl;void DisplayStudentInformation()using namespace std;using namespace studentInformation;int displayVectorSize = studentVector.size();if (displayVectorSize = 0)cout << "-" << endl;cout << "当前系统中没有学生信息,请先添加学生信息!" << endl;cout << "-" << endl;elseSearchStudent();if (flagStudentFound = 0)studentVectorflagStudentChoose.Student_DisplayInformation();bool CmpGrade(Student student1, Student student2)return student1.Student_ReadGrade() > student2.Student_ReadGrade(); /如果student1成绩大于student2,则返回1.这样能实现成绩的降序排列void RankByGrade()using namespace studentInformation;using namespace std;int rankVectorSize = studentVector.size();if (rankVectorSize = 1)studentVector0.Student_WriteGradeRank(1);elsesort(studentVector.begin(), studentVector.end(), CmpGrade); /使用sort必须加上#include algorithm和std。sort的前两个参数是指针int i = 0;for (i = 0; i <= rankVectorSize-1; i+)if (i>=1)&&(studentVectori.Student_ReadGrade() = studentVectori - 1.Student_ReadGrade()studentVectori.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成绩大于student2,则返回1.这样能实现成绩的降序排列void 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的前两个参数是指针int i = 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 + 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(studentVector.begin(), studentVector.end(), CmpID);cout << "-" << endl;cout << "排序成功!" << endl;cout << "-" << endl;void DisplayAllStudentInformation()using namespace std;using namespace studentInformation;int displayVectorSize = studentVector.size();int i;if (displayVectorSize = 0)cout << "-" << endl;cout << "当前系统中没有学生信息!" << endl;cout << "-" << endl;elsecout << "-" << endl;cout << "姓名 学号 综合成绩 综合排名" << endl;for (i = 0; i < displayVectorSize; i+)cout << studentVectori.Student_ReadName() << " "<< studentVectori.Student_ReadID() << " "<< studentVectori.Student_ReadTotalGrade() << " "<< studentVectori.Student_ReadTotalGradeRank() << endl;cout << "-" << endl;/-以下是主函数-void main

    注意事项

    本文(C++实现:简单的学生信息管理系统(控制台程序).doc)为本站会员(豆****)主动上传,淘文阁 - 分享文档赚钱的网站仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知淘文阁 - 分享文档赚钱的网站(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于淘文阁 - 版权申诉 - 用户使用规则 - 积分规则 - 联系我们

    本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

    工信部备案号:黑ICP备15003705号 © 2020-2023 www.taowenge.com 淘文阁 

    收起
    展开