学生成绩管理C++版
【标题】学生成绩管理的设计与实现
【开发语言】C++
【主要技术】STL
【概要设计】类名:student
类成员:No、Name、Math、Eng、Chn、Cpro、Sum
成员函数:getname、getno、getsum
【基本功能】使用list容器实现对学生成绩类的基本操作:增加、删除、查询、排序
【测试数据】功能测试:按提示输入5组正确的正确的数据和5组有问题的数据,查看程序能否运行正确
性能测试:随机生成1、5、10、15万条数据,查看程序完成按总分排序所用的时间及打印完成的时间
【测试结果】功能测试:基本功能运行正确,没有进行异常处理
性能测试:
| 数据量(万条) | 1 | 5 | 10 | 15 |
| 排序所用时间(秒) | 1.7 | 25.9 | 02:35.0 | 07:49.9 |
| 完成打印所用时间(秒) | 21.2 | 01:59.9 | 05:40.7 | 11:43.5 |
| 排序所需内存(K) | 640 | 3132 | 6264 | 9388 |
C语言版随机生成等量的数据情况对比:
| 数据量(万条) | 1 | 5 | 10 | 15 |
| 排序所用时间(秒) | 0.7 | 12.2 | 02:21.6 | 7:10.7 |
| 完成打印所用时间(秒) | 8.0 | 48.7 | 03:33.5 | 09:10.7 |
| 排序所需内存(K) | 1064 | 4700 | 9392 | 14050 |
对比结果:使用C语言实现排序和打印所用时间少,消耗内存更多(C语言版地址:http://www.cnblogs.com/forerve/p/4177245.html)
【详细设计】
#include<iostream>
#include<string>
#include<list>
#include<algorithm>
using namespace std;
class student{
private:
string No;
string Name;
double Math;
double Eng;
double Chn;
double Cpro;
double Sum;
public:
student(string no, string name, double math, double eng,
double chn, double cpro){
No = no;
Name = name;
Math = math;
Eng = eng;
Chn = chn;
Cpro = cpro;
Sum = math + eng + chn + cpro;
}
friend ostream& operator <<(ostream& out, student& S)
{
out << "\t" << S.No << "\t" << S.Name << "\t" << S.Math << "\t"
<< S.Eng << "\t" << S.Chn << "\t" << S.Cpro << "\t" << S.Sum;
return out;
}
const string getno()
{
return No;
}
const string getname()
{
return Name;
}
const double getsum()
{
return Sum;
}
~student(){
}
};
void main_remid(); /*输出主要提示信息 */
void score_remind(); /*输出成绩提示信息*/
int add(list<student> &lst); /*增加学生*/
int find(list<student> &lst); /*查询学生信息*/
int del(list<student> &lst); /*删除学生*/
void sort_sum(list<student> &lst); /*按总成绩降序打印学生成绩*/
void sort_no(list<student> &lst); /*按学号升序打印学生成绩*/
bool cmp_no(student& st1, student& st2); /*用于sort的比较函数*/
int main()
{
list<student> lst; /*使用list容器存储学生信息*/
char op = ' ';
main_remid();
while(op != 'q')
{
cin >> op;
switch(op)
{
':
sort_no(lst);
break;
':
add(lst);
break;
':
find(lst);
break;
':
del(lst);
break;
':
sort_sum(lst);
break;
':
main_remid();
break;
default:
cout << "输入指令未知,请重新输入" << endl;
break;
}
if(op != 'q')
cout << " 请继续选择您想要的操作:" << endl;
}
;
}
/*增加学生*/
int add(list<student> &lst)
{
string No;
string Name;
double Math;
double Eng;
double Chn;
double Cpro;
cout << " 请输入要增加学生的学号:" << endl;
cin >> No;
for(list<student>::iterator it=lst.begin(); it!=lst.end(); it++)
if(No == it->getno()){
cout << "添加失败,此学号已存在,请重新操作" << endl;
;
}
cout << " 请输入要增加学生的姓名" << endl;
cin >> Name;
cout << " 请输入要增加学生的数学成绩:" << endl;
cin >> Math;
cout << " 请输入要增加学生的英语成绩:" << endl;
cin >> Eng;
cout << " 请输入要增加学生的语文成绩:" << endl;
cin >> Chn;
cout << " 请输入要增加学生的C语言成绩:" << endl;
cin >> Cpro;
student *st = new student(No, Name, Math, Eng, Chn, Cpro);
lst.push_back(*st);
}
/*查询学生信息*/
int find(list<student> &lst)
{
cout << "请输入要查询学生的学号:" << endl;
string no;
cin >> no;
for(list<student>::iterator it=lst.begin(); it!=lst.end(); it++)
{
if(no == it->getno())
{
score_remind();
cout << *it << endl;
;
}
}
cout << "不存在此学号,请重新选择操作" << endl;
}
/*删除学生*/
int del(list<student> &lst)
{
cout << " 请输入要删除学生的学号:" << endl;
string no;
string name;
cin >> no;
for(list<student>::iterator it=lst.begin(); it!=lst.end(); it++)
if(no == it->getno())
{
no = it->getno();
name = it->getname();
lst.erase(it);
cout << "学生" << no << " " << name << "删除成功" << endl;
;
}
cout << " 删除失败,不存在此学号" << endl;
}
/*按学号升序打印学生成绩*/
void sort_no(list<student> &lst)
{
list<student> temp;
temp.push_front(*lst.begin());
for(list<student>::iterator it=++lst.begin(); it!=lst.end(); it++)
{
list<student>::iterator jt = temp.begin();
while(jt!=temp.end() && strcmp(it->getno().c_str(), jt->getno().c_str()))
jt++;
temp.insert(jt, *it);
}
score_remind();
for(list<student>::iterator it=temp.begin(); it!=temp.end(); it++)
{
cout << *it << endl;
}
}
/*用于sort的比较函数*/
/*bool cmp_no(const student& st1, const student& st2)
{
return st1.getno() < st2.getno();
}*/
/*按成绩升序打印学生成绩*/
void sort_sum(list<student> &lst)
{
list<student> temp;
temp.push_front(*lst.begin());
for(list<student>::iterator it=++lst.begin(); it!=lst.end(); it++)
{
list<student>::iterator jt = temp.begin();
while(jt!=temp.end() && it->getsum()<jt->getsum())
jt++;
temp.insert(jt, *it);
}
score_remind();
for(list<student>::iterator it=temp.begin(); it!=temp.end(); it++)
{
cout << *it << endl;
}
}
/*输出主要提示信息 */
void main_remid()
{
cout << "\t\t\t学生成绩类" << endl << endl;
cout << "\t\t1.查询所有学生的成绩信息" << endl;
cout << "\t\t2.增加学生" << endl;
cout << "\t\t3.查找学生" << endl;
cout << "\t\t4.删除学生" << endl;
cout << "\t\t5.查看总分排名" << endl;
cout << "\t\t6.查看提示" << endl;
cout << "\t\tq.退出系统" << endl << endl;
}
/*输出成绩提示信息*/
void score_remind()
{
cout << "\t\t\t 学生成绩信息" << endl << endl;
cout << "\t学号\t" << "姓名\t" << "数学\t" << "英语\t"
<< "语文\t" << "C语言\t" << "总成绩" << endl;
}

学生成绩管理C++版的更多相关文章
- 学生成绩管理C语言版
[标题]学生成绩管理的设计与实现 [开发语言]C语言 [概要设计]使用结构体存储学生的学号.姓名和成绩信息,实现对学生成绩类的基本操作:增加.删除.查询.排序 [测试数据]按提示输入5组正确的正确的数 ...
- JAVA课程设计 学生成绩管理
学生成绩管理 可实现功能: 添加学生功能:姓名.学号.性别.出生年月日.(学号自动生成且唯一) 添加学生成绩功能:每个人都有数学.Java与体育四门课,可分课程输入成绩. 根据学生学号查找学生成绩功能 ...
- C语言文件实现学生成绩管理
C语言实现学生成绩管理 项目简介 用C语言的链表及文件操作实现学生成绩的管理,实现主要的添加.修改.删除.查询的主要功能,并在程序关闭时将数据存储在二进制的文件中并加密.下一次打开程序,先解密二进制文 ...
- 开学考试学生成绩管理Java
首先student类 package xuexi; public class Student { private String stunumber; private String name; priv ...
- JAVA基础代码分享--学生成绩管理
问题描述: 从键盘读入学生成绩,找出最高分,并输出学生成绩等级. 成绩>=最高分-10 等级为’A’ 成绩>=最高分-20 等级为’B’ 成绩>=最高分-30 等级为’C’ ...
- JAVA课程设计个人博客 学生成绩管理 201521123001 张陈东芳
1. 团队课程设计博客链接 http://www.cnblogs.com/kawajiang/p/7062407.html 2.个人负责模块或任务说明 我主要负责实现学生信息的添加功能.学生成绩的录入 ...
- c++链表实现学生成绩管理系统(简易版)
#include<iostream> using namespace std; typedef struct student{ int id;//学号 string sex; string ...
- 简易学生成绩管理管理系统(java描述)
没正式学过java,但是系统学过C++后,初略的看了下java的基本语法,于是我就尝试着用java来写个简单的学生管理系统,功能不齐全,以后有空再补充吧. 写的时候定义了不同的包名字,如jeaven1 ...
- JAVA课程设计个人博客 学生成绩管理 201521123023 戴建钊
1. 团队课程设计博客链接 http://www.cnblogs.com/kawajiang/p/7062407.html 2.个人负责模块或任务说明 我主要负责实现随机生成10万个学生及其姓名.学号 ...
随机推荐
- MYSQL优化_MYSQL分区技术[转载]
MySQL分区技术是用来减轻海量数据带来的负担,解决数据库性能下降问题的一种方式,其他的方式还有建立索引,大表拆小表等等.MySQL分区按照分区的参考方式来分有RANGE分区.LIST分区.HASH分 ...
- VSCode里的一些有用的插件
1.EaseServer 作用:开启本地 http server,然后在browser里打开html: 在调试页面的时候,打开页面比较方便,不需要先开启server,再打开html 2.Debugge ...
- js实现多行图片点击(自动)左右无缝轮播特效
/*效果图*/ HTML: <div class="scroll"> <div class="picbox"> ...
- echarts雷达图点击事件
最近看见别人问的问题,点击雷达图的拐点,获取点击数据的问题,直接上代码. echarts配置问题:https://www.douban.com/note/509404582/ <!doctype ...
- 实现简单的跨站脚本攻击(XSS)
我们来通俗的了解一下什么是跨站脚本攻击(XSS):在表单中提交 一段 js代码 ,提交的内容被展示到页面时 ,js会被浏览器解析 打个比方吧,比如我现在写的这篇博客,写完以后我要发表对吧? 发表这个过 ...
- 学习Sass笔记之概念篇
1 什么是CSS预处理器 首先我们了解一下什么是CSS预处理器:通俗的说,“CSS 预处理器用一种专门的编程语言,进行 Web 页面样式设计,然后再编译成正常的 CSS 文件,以供项目使用.CSS 预 ...
- asp.net core源码飘香:Logging组件
简介: 作为基础组件,日志组件被其他组件和中间件所使用,它提供了一个统一的编程模型,即不需要知道日志最终记录到哪里去,只需要调用它即可. 使用方法很简单,通过依赖注入ILogFactory(Creat ...
- Cookie中文乱码问题
页面一登录,页面二保存用户信息,放入Cookies里. 但是Cookies放入中文会引起编码问题,如报错“Control character in cookie value, consider BAS ...
- 利用jackson-databind,复杂对象对象和json数据互转
如果简单对象,那么转换的方式比较多,这里指的复杂对象,是指对象里面存在cycle引用,比如: /** * @author ding * */@Entity@Table(name = "ser ...
- NuGet(Nuget Packages)
Nuget是一个.NET平台下的开源的项目,它是Visual Studio的扩展.在使用Visual Studio开发基于.NET Framework的应用时,Nuget能把在项目中添加.移除和更新引 ...