Я пытаюсь напечатать для каждого заданного интервала его число вхождений во входных данных, например, для ввода: 4 1 5 6 8 6 8 4 7 программа должна вывести: 1 5: 1 6 8: 2 4 7: 1 вот мой код
struct Interval
{
long unsigned int start, end;
};
bool operator<(const Interval& i1, const Interval& i2)
{
bool renvoie = true;;
if(i1.start < i2.start)
{
renvoie = true;
}
else if(i1.start== i2.start && i1.end>=i2.end)
renvoie = true;
else
renvoie = false;
return renvoie;
}
bool operator==(const Interval& i1, const Interval& i2)
{
return (i1.start==i2.start && i1.end==i2.end);
}
int main()
{
int nbr;
cin>>nbr;
map<Interval, int> occurence;
for(int i=0;i<nbr;i++)
{
Interval jetable;
cin>>jetable.start;
cin>>jetable.end;
occurence[jetable]++;
}
for(map<Interval,int>::iterator it = occurence.begin(); it!=occurence.end(); ++it)
{
cout << (it->first).start <<" " <<(it->first).end<<" "<<(it->second)<<endl;
}
}
проблема в том, что два одинаковых интервала считаются разными, почему ??