题解 | #明明的随机数#
明明的随机数
https://www.nowcoder.com/practice/3245215fffb84b7b81285493eae92ff0
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
void printSet(set<int>& s) {
for (set<int>::iterator it = s.begin(); it != s.end(); it++) {
cout << *it << endl;
}
}
int main() {
set<int> s1;
int a, b;
cin>>a;
for (int i = 0; i < a; i++) {
cin >> b;
s1.insert(b);
}
printSet(s1);
}
// 64 位输出请用 printf("%lld")
set不允许容器中有重复的元素 所有元素都会在插入时自动被排序
查看9道真题和解析
