set的用法

 1 #include<iostream>
 2 #include<set>
 3 using namespace std;
 4 
 5 int main()
 6 {
 7     set<int> iset = { 2, 5, 6, 3, 9, 5, 2 };   //按照关键字排序
 8     set<int>::const_iterator set_it = iset.begin();
 9     for (; set_it != iset.end(); ++set_it)
10         cout << *set_it << " ";
11     cout << endl;
12     return 0;
13 }

输出结果:

猜你喜欢

转载自www.cnblogs.com/sunbines/p/9155002.html
今日推荐