还有一分未拿到,加油!
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include<map>
using namespace std;
class Grade
{
public:
int GP=-1;
int GM=-1;
int GL=-1;
int GALL=-1;
Grade(){}
Grade(int x, int y, int z)
{
GP = x;
GM = y;
GL = z;
}
void add_all()
{
double temp = GM > GL ? (0.4*GM + 0.6*GL) : GL;
GALL = round(temp);
}
};
typedef pair<string, Grade> PAIR;
bool cmp_by_value(const PAIR& lhs, const PAIR& rhs) {
return lhs.second.GALL> rhs.second.GALL;
}
struct CmpByValue {
bool operator() (const pair<string, Grade> &gra, const pair<string, Grade> &grb)
{
return gra.second.GALL > grb.second.GALL;
}
};
map<string, Grade>stu;
int M, N, L, K, a, b, c;
string str;
int main()
{
cin >> M>>N>>L;
for (int i = 0; i < M; i++)
{
cin >> str >> a;
stu[str].GP=a;
}
for (int i = 0; i < N; i++)
{
cin >> str >> a;
stu[str].GM=a;
}
for (int i = 0; i < L; i++)
{
cin >> str >> a;
stu[str].GL=a;
stu[str].add_all();
}
vector<PAIR> scoren(stu.begin(), stu.end());
sort(scoren.begin(), scoren.end(), CmpByValue());
for (int i = 0; i < scoren.size(); i++)
{
if (scoren[i].second.GP >= 200 && scoren[i].second.GALL >= 60 && scoren[i].second.GALL <= 100)
{
cout << scoren[i].first << " " << scoren[i].second.GP << " " \
<< scoren[i].second.GM << " " << scoren[i].second.GL \
<< " " << scoren[i].second.GALL << endl;
}
}
system("pause");
return 0;
}
网友评论