答案
2025-10-07 21:41:57
发布于:福建
2阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
long long n;
int main( ) {
set<long long> s;
cin >> n;
for (int i = 1 ; i <= n ; i++ ) {
long long x;
cin >> x;
s.insert(x);
}
cout << s.size() << endl;
for (auto i : s) cout << i << " ";
return 0;
}
#include <iostream>
#include <algorithm>
using namespace std;
long long n;
const long long N = 150;
long long array_[N] , cnt = 0;
//bool comper(long long x , long long y) {
//return x > y;
//}
int main( ) {
scanf("%lld" , &n);
for (int i = 1 ; i <= n ; i++) {
scanf("%lld" , &array_[i]);
}
sort(array_ + 1 , array_ + n + 1);
//for (int i = 0 ; i <= n ; i++) {
//cout << a[i] << " ";
//}
for (int i = 1 ; i <= n ; i++) {
if (array_[i] != array_[i - 1]) cnt++;
}
printf("%lld\n" , cnt);
for (int i = 1 ; i <= n ; i++) {
if (array_[i] != array_[i - 1]) printf("%lld " , array_[i]);
}
return 0;
}
这里空空如也


有帮助,赞一个