set集中查找find

来源:互联网 发布:怎样抢到淘宝秒杀产品 编辑:程序博客网 时间:2024/05/16 02:34
#include <iostream>#include <set>using namespace std;typedef set<int> SETINT; // SETINT是别名,int main(){SETINT a;a.insert(67);a.insert(7);a.insert(-2);    SETINT::const_iterator i;for (i = a.begin(); i != a.end(); ++i){cout << *i << endl;}SETINT::iterator i_found = a.find(70);if (i_found != a.end())cout << "找到了," << *i_found << endl;elsecout << "没有找到," << endl;return 0;}

0 0
原创粉丝点击