📄 stat.cpp
字号:
#include<iostream>
#include<fstream>
#include<string>
#include<algorithm>
#include"stat.h"
#include"sdt.h"
using std::cin;
using std::cout;
using std::vector;
using std::ofstream;
using std::map;
using std::string;
using std::endl;
void stat_menu()
{
cout<<"*********************08欧洲杯冠军意大利***********************"<<"\n"
<<"******************欢迎光临学生信息统计系统********************"<<"\n"
<<"****************************^_^*******************************"<<"\n"
<<"* 1.成绩统计 ●█〓██▄▄▄▄▄▄ ●GOAL● *"<<"\n"
<<"* 2.返回上级菜单 ▄▅██████▅▄▃▂ *"<<"\n"
<<"* ██████████████ *"<<"\n"
<<"* ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲◤ *"<<"\n"
<<"* 制作人:剑侠£影枫 *"<<"\n"
<<"* 联系QQ:32861410 *"<<"\n"
<<"* E-mail:youxiaoitaly@hotmail.com *"<<"\n"
<<endl;
select_menu();
int select_stat;
while(cin>>select_stat)
{
switch(select_stat)
{
case 1:system("cls");tongji();break;
case 2:come_back();
default:cout<<"输入无效,返回重新输入!";
}
}
}
void tongji() //统计显示每个班每一科目的成绩
{
vector<student>::const_iterator beg=svec.begin();
vector<student>::const_iterator end=svec.end();
while(beg!=end)
{
vector<student>::const_iterator copy_beg=beg;
vector<student>::const_iterator copy_end=find_if(beg,end,GT_cls(beg->s_class));
map<string,double>::const_iterator m_it=beg->s_score.begin(); //控制各科目的循环
map<string,double>::const_iterator m1_it=beg->s_score.end(); //控制各科目的循环
int nCurIdx = 0; //增加一个索引,记录当前正在处理的科目位置
cout<<beg->s_class<<" 成绩统计情况如下: "<<endl;
while(m_it!=m1_it)
{
/*遍历每一科目的时候重置各项为0*/
double max=0.0;
double min=0.0;
double ave=0.0;
double sum=0.0;
int cnt=0;
beg=copy_beg;
max=min=m_it->second;
cout<<"\t\t"<<m_it->first<<" : ";
for(;beg!=copy_end;++beg) //for(;beg!=end;++beg) //控制班上同学的循环
{
map<string,double>::const_iterator mm_it=beg->s_score.begin(); //mm_it指向每1科目
//调整当前统计的科目成绩的位置
int nIdx = 0;
while(nIdx++<nCurIdx) //控制mm_it指向下一个应该被处理的科目
++mm_it;
if((mm_it->second)>max)
max=mm_it->second;
if((mm_it->second)<min)
min=mm_it->second;
sum+=mm_it->second;
++cnt;
}
++nCurIdx; //处理完一科 nCurIdx加1
cout<<"平均分:"<<sum/cnt<<"\t"<<"最高分;"<<max<<"\t"<<"最低分:"<<min<<endl;
++m_it;
}
beg=copy_end;
}
back_main();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -