关于#c++#的问题,如何解决?

img


这个有点综合不是很懂,希望各位专家无聊的话能抽空指点,不胜感觉。


typedef pair<string, int> PAIR;

bool cmp_by_value(const PAIR &lhs, const PAIR &rhs)
{
    return lhs.second < rhs.second;
}

int main()
{
    map<string, int> m1 = {{"T", 1}, {"B", 2}, {"C", 3}, {"E", 4}};
    map<string, int> m2 = {{"E", 5}, {"F", 6}, {"G", 7}, {"H", 8}};

    m2.insert(m1.begin(), m1.end());

    vector<PAIR> m3(m2.begin(), m2.end());
    sort(m3.begin(), m3.end(), cmp_by_value);

    for (auto it = m3.begin(); it != m3.end(); ++it)
        cout << it->first << " - " << it->second << endl;

    return 0;
}