# include <iostream>
# include <set>
using namespace std;
//宏定义
typedef set<int> SETINT;
int main(){
SETINT a;
a.insert(23);
a.insert(-1);
a.insert(78);
a.insert(100);
a.insert(5);
SETINT::const_iterator i;
for(i=a.begin(); i!=a.end();i++){
cout<<*i<<endl;
}
cout<<endl;
//find查找是否含有-1,可以查找不能直接修改,只有删除在插入
//返回加个是迭代器
SETINT::iterator i_found = a.find(-1);
if(i_found!=a.end()){
cout<<*i_found<<endl;
}
return 0;
}
set用法2之查找
最新推荐文章于 2025-05-16 00:01:22 发布