#include <bits/stdc++.h>
using namespace std;
int dist[2];
struct cmp {
bool operator() (const int &a, const int &b) {
return dist[a] < dist[b];
}
};
set<int, cmp> s;
int main() {
dist[0] = 2;
dist[1] = 2;
s.insert(1);
s.insert(0);
for(set<int>::iterator it = s.begin(); it != s.end(); ++it) {
cout << *it << " " << dist[*it] << endl;
}
}
The above code outputs:
1 2
Why is this true? Should it not output:
1 2
0 2
Thank you!
Aucun commentaire:
Enregistrer un commentaire