STL的set iterator

来源:互联网 发布:怎样安装办公软件 编辑:程序博客网 时间:2024/05/21 07:09
#include <bits/stdc++.h>using namespace std;typedef long long ll;using namespace std;struct my {    int x, y;    my(int x0, int y0): x(x0), y(y0){}    friend inline bool operator < (const my &a, const my &b){        return a.y<b.y;    }};set<my> S;typedef set<my>::iterator it;int main(){    S.insert(my(1,2));    S.insert(my(2,3));    it t=S.begin();    S.erase(t);    S.insert(my(3,4));    for (it i=S.begin(); i!=S.end(); i++){        my cnm=*i;        cout<<cnm.x<<" "<<cnm.y<<endl;    }}

原创粉丝点击