题解 | #明明的随机数#
明明的随机数
https://www.nowcoder.com/practice/3245215fffb84b7b81285493eae92ff0
去重复+排序,一眼用set。
#include <iostream>
#include <vector>
#include <set>
void DelDupAndSort(std::vector<int>& nums){
std::set<int> occ(nums.begin(), nums.end());
for(auto ele : occ){
std::cout << ele << std::endl;
}
}
int main(int argc, char* argv[]){
int N;
std::cin >> N;
std::vector<int> nums(N, 0);
int num;
int i = 0;
while(std::cin >> num){
nums[i++] = num;
}
DelDupAndSort(nums);
return 0;
}