What will be the output of the given program?
#include <bits/stdc++.h>
using namespace std;
struct Point
{
int x, y;
bool operator<(Point &oth)
{
return this->y > oth.y;
}
};
int main()
{
Point arr[] = {{3, 10}, {2, 8}, {5, 4}};
int n = sizeof(arr) / sizeof(arr[0]);
sort(arr, arr + n);
for (auto i : arr)
{
cout << i.x << " " << i.y << endl;
}
return 0;
}
5 4
2 8
3 10
3 10
2 8
5 4
2 8
3 10
5 4
3 10
5 4
2 8
This question is part of this quiz :
C++ STL Mutating Algorithms