set:二叉搜索树维护的容器
#include <iostream>
#include <set>
using namespace std;
int main(){
//声明
set<int> s;
//插入元素
s.insert(1);
s.insert(3);
s.insert(5);
//查找元素
set<int>::iterator ite;
ite=s.find(1);
if(ite==s.end()){
cout<<"not found"<<endl;
} else{
cout<<"found"<<endl;
}
//删除元素
s.erase(3);
//其他查找元素的方法
if(s.count(3)!=0){
cout<<"found"<<endl;
} else{
cout<<"no found"<<endl;
}
//遍历
for(ite=s.begin();ite!=s.end();++ite){
cout<<*ite<<" ";
}
return 0;
}