Previously i have overloaded the < operator and i have sorted a structure then i tried to overload the > operator but i did not worked.want some help to find out the queries.
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
struct a
{
int num1;
int num2;
bool operator > (const a& rhs) const
{
return num1>rhs.num1;
}
};
int main()
{
a array[1000];
for(int i=0; i<2; i++)
{
cin>>array[i].num1>>array[i].num2;
}
sort(array, array+2);
for(int i=0; i<2; i++)
{
cout<<array[i].num1<<" "<<array[i].num2<<endl;
}
}
Aucun commentaire:
Enregistrer un commentaire