AcWing 425. 明明的随机数
原题链接
简单
作者:
王小强
,
2021-02-09 10:38:39
,
所有人可见
,
阅读 200
Simulation!
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n, x;
vector<int> nums;
bool exists(int val) {
for (int i = 0; i < nums.size(); ++i)
if (nums[i] == val) return true;
return false;
}
int main(void) {
cin >> n;
while (n--) {
cin >> x;
if (not exists(x)) nums.emplace_back(x);
}
sort(begin(nums), end(nums));
// output
printf("%d\n", nums.size());
for (const auto& x : nums) printf("%d ", x);
printf("\n");
}