题解 | #明明的随机数#

明明的随机数

https://www.nowcoder.com/practice/3245215fffb84b7b81285493eae92ff0

// HJ3 明明的随机数.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <iostream>
#include<bits/stdc++.h>

using namespace std;

class Solution {
public:
	void Random(vector<int>& str);
};

void Solution::Random(vector<int>& str)
{
	sort(str.begin(), str.end());
	str.erase(unique(str.begin(), str.end()), str.end());
	for (auto x : str)
		cout << x << endl;
}
int main()
{
	Solution a;
	int n;
	while (cin >> n)
	{
		vector<int>dp(n);
		for (int i = 0; i < n; i++)
			cin >> dp[i];
		a.Random(dp);
	}
	return 0;
}

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务