What will be printed out as a result of the following program (C++11):
#include <utility>
#include <vector>
#include <algorithm>
#include <iostream>

typedef std::pair<int, int> p_int;

int main()
    std::vector<p_int> v;

    v.push_back(std::make_pair(3, 2));
    v.push_back(std::make_pair(2, 3));
    v.push_back(std::make_pair(1, 4));
    v.push_back(std::make_pair(1, 3));

    std::sort(v.begin(), v.end());
    for (auto &x : v)
        std::cout << x.first << x.second;
In the case of unequal comparison (<, >) the first element is compared first and only if equal the second.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
C++ quizzes
Sign Up Now
or Subscribe for future quizzes