Created
February 28, 2022 16:43
-
-
Save imoasislee/2b9916bac92ce744b41a37419c918008 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// set | |
#include <iostream> | |
#include <cstring> | |
#include <set> // 使用multiset和set | |
using namespace std; | |
int main() | |
{ | |
set<int> st; | |
int a[10] = {1,3,9,2,87,12,91,55,90,90}; // 包含重复元素90 | |
for (int i=0; i<10; ++i) | |
{ | |
st.insert(a[i]); | |
} | |
cout << st.size() << endl; // size=9 | |
set<int>::iterator i; | |
for(i=st.begin(); i!=st.end(); ++i) | |
{ | |
cout << *i << ","; // 逐项输出 | |
} | |
cout << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment