#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
int a[10]={1,2,3,3,4,2,4,5,9,10};
sort(a,a+10);
int n=10,i;
for(i=0;i<n;i++){
printf("%d ",a[i]);
}
printf("\n");
n=unique(a,a+10)-a;
for(i=0;i<n;i++){
printf("%d ",a[i]);
}
printf("\n");
for(i=0;i<10;i++){
printf("%d ",a[i]);
}
return 0;
}
/*
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N = 100000;
int a[N+5];
int main()
{
int n;
while (cin>>n)
{
for (int i = 0;i < n;++i)
{
scanf("%d",&a[i]);
}
sort(a,a+n);
n = unique(a,a+n) - a;//?????
for (int i = 0;i < n;++i)
{
printf("%d ",a[i]);
}
puts("");
}
return 0;
}
*/
sort +unique 实现去重
最新推荐文章于 2024-06-10 21:25:11 发布