#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
int n, a[5211314], len;
int main() {
cin >> n;
for (int i = 1; i <= n; ++ i) {
cin >> a[i];
}
sort(a + 1, a + 1 + n);
len = unique(a + 1, a + 1 + n) - (a + 1);
//len是去重后的数组长度
cout << "len = " << len << endl;
for (int i = 1; i <= len; ++ i) {
cout << a[i] << " ";
}
}
标签:std,unique,int,len,c++,include
From: https://www.cnblogs.com/jueqingfeng/p/17409162.html