美文网首页
1137 Final Grading(25 分)

1137 Final Grading(25 分)

作者: zjh3029 | 来源:发表于2018-08-10 17:38 被阅读0次

还有一分未拿到,加油!

#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;
}

相关文章

网友评论

      本文标题:1137 Final Grading(25 分)

      本文链接:https://www.haomeiwen.com/subject/tkslbftx.html