题目描述
代码:
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int n;
cin>>n;
int A[n];
for(int i = 0; i < n; i++){
cin>>A[i];
}
sort(A,A+n);
int slow = 0,fast = 0;
while(fast < n){
if(slow != fast){
A[slow] = A[fast];
}
if(fast == n-1){
break;
}
if(A[fast + 1] != A[fast]){
slow++;
}
fast++;
}
cout<<slow+1<<endl;
for(int i = 0; i <= slow; i++){
cout<<A[i]<<" ";
}
return 0;
}
标签:slow,洛谷,int,fast,++,随机数,include,指针
From: https://www.cnblogs.com/satsuki26681534/p/18055069