更新 '2.2.cpp'

This commit is contained in:
Kirigaya Kazuto 2017-09-17 21:32:21 +08:00
parent 6a1933bcc1
commit e55f645773

14
2.2.cpp
View File

@ -99,21 +99,23 @@ int main()
ofstream ofs("result/2.2.csv"); ofstream ofs("result/2.2.csv");
#define cout ofs #define cout ofs
cout<<"行业,最低工资,最高工资,平均工资,数量"<<endl; cout<<"行业,最低工资(平均),最高工资(平均),平均工资,数量"<<endl;
for(auto& pr:mp) for(auto& pr:mp)
{ {
int sum=0; int sum=0;
int lowest=9999999; int lowsum=0;
int highest=-1; int highsum=-1;
int szVec=pr.second.size(); int szVec=pr.second.size();
for(auto& pk:pr.second) for(auto& pk:pr.second)
{ {
sum+=pk.ave(); sum+=pk.ave();
lowest=min(lowest,pk.low); lowsum+=pk.low;
highest=max(highest,pk.high); highsum+=pk.high;
} }
sum/=szVec; sum/=szVec;
cout<<pr.first<<","<<lowest<<","<<highest<<","<<sum<<","<<szVec<<endl; lowsum/=szVec;
highsum/=szVec;
cout<<pr.first<<","<<lowsum<<","<<highsum<<","<<sum<<","<<szVec<<endl;
} }
#undef cout #undef cout