set用法2之查找

来源:互联网 发布:购票软件排行 编辑:程序博客网 时间:2024/06/15 08:22
# 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;} 
0 0
原创粉丝点击