#include <iostream>
#include <set>
using namespace std;
struct node{
int x, y;
bool operator< (const node& other)const
{
//if(x != other.x)
return x < other.x;
}
};
int main()
{
set<node>s;
s.insert({2, 2});
s.insert({2, 3});
s.insert({2, 4});
s.insert({2, 1});
for(node it : s) cout << it.x << ' ' << it.y << endl;
}
输出:2 2
#include <iostream>
#include <set>
using namespace std;
struct node{
int x, y;
bool operator< (const node& other)const
{
if(x != other.x)
return x < other.x;
}
};
int main()
{
set<node>s;
s.insert({2, 2});
s.insert({2, 3});
s.insert({2, 4});
s.insert({2, 1});
for(node it : s) cout << it.x << ' ' << it.y << endl;
}
输出:2 1
2 4
2 3
2 2
#include <iostream>
#include <set>
using namespace std;
struct node{
int x, y;
bool operator< (const node& other)const
{
//if(x != other.x)
return x < other.x;
}
};
int main()
{
multiset<node>s;
s.insert({2, 2});
s.insert({2, 3});
s.insert({2, 4});
s.insert({2, 1});
s.insert({2, 1});
for(node it : s) cout << it.x << ' ' << it.y << endl;
}
输出:2 2
2 3
2 4
2 1
2 1