是一个内部自动有序且不含重复元素的容器
#include
using namespace std;
定义一个set
set
set
set容器内元素访问
set
除开vector和string之外的stl容器都不支持*(it+i)的访问方式
#include
#include
using namespace std;
int main(){//set内的元素自动递增排序,且自动去除了重复元素
set
st.insert(3);//将3插入到set中
st.erase(st.find(3));//利用find()函数找到3,然后erase删除他
set
printf("%dn",*it);
st.erase(it,st.end());//删除元素30至set末尾之间的元素
for(set
printf("%d",*it);
}
printf("%dn",st.size());//输出set内元素的个数
set.clear();//清空set
return 0;
}



