c++中set的用法
#include<iostream> #include<vector> #include<algorithm> #include<set> using namespace std; int main() { /*初始化方式*/ vector<int>vec = { 6, 2, 1, 4, 5 }; set<int>iset(vec.begin(), vec.end()); //int a[5] = { 1, 2, 3, 4, 5 }; //set<int > setc(a, a + 5); //数组a初始化一个set; cout << iset.count(6) << endl; auto it = iset.begin(); while (it!=iset.end()) { cout << *it << endl; it++; } system("pause"); return 0; }