set为数学上的集合--每个数字最多只出现一次,所有的元素都会根据键值自动排序。
set<int> s;
首先插入删除元素:
插入:s.insert(a) 删除:s.erase(a)
生成某个值元素的个数:int num=s.count(a);(我觉得就是1和0两个选择吧)
很方便用来判断集合中有没有某个元素a。
使用迭代器遍历集合:
set<int>::iterator it=s.begin();it!=s.end();++it
清空集合:
s.clear();
其余有很多,先写我用过的