set && muliset

#include <set>
#include <iostream>
#include <cstdio>
#include <cctype>
using namespace std;
typedef long long ll;
set < ll > s;
inline ll read () {
    ll x=0,f=1;
    char ch=getchar();
    while(!isdigit(ch)) {
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(isdigit(ch)) {
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}
int n;
signed main() {
    n=read();
    for(register int i=1; i<=n; i++) s.insert(read());
    for(set < ll > ::iterator it=s.begin(); it!=s.end(); it++) cout<<*it<<' ';
    return 0;
//insert(value)    向集合中插入一个元素
//erase()    擦除元素中的一个或者一段元素
//clear()    清除集合中的元素
//查找
//find()    查找value的值,返回下标位置,否则,返回最后一个元素后面一个位置(即迭代器的end)
//容量
//empty()    判断集合是否为空
//size()    返回集合中的元素个数
//max_size()    返回集合的最大容量
//迭代器
//begin()    返回开头的迭代器
//end() 返回结尾的迭代器
//rbegin() 反向遍历的首个位置迭代器
//rend()    反向遍历的最后位置的迭代器
//count() 判断某一键值是否在set出现过了
//erase(iterator)  ,删除定位器iterator指向的值
//erase(first,second),删除定位器first和second之间的值
//erase(key_value),删除键值key_value的值
}

 muliset就不提了 muliset 是set的“升级版” ;

定义方法

muliset <int> m;
muliset <int , vector<int> , greater<int> > m;
muliset <int , vector<int> , less<int> >m;

 

posted @ 2019-01-31 11:22  Isaunoya  阅读(128)  评论(0编辑  收藏  举报
TOP