10 20 40 32 67 40 20 89 300 400 15
8 15 20 32 40 67 89 300 400
#include<stdio.h> #include<algorithm> using namespace std; int main() { int n,i,k,a[1001]; while(~scanf("%d",&n)) { for(i=0;i<n;++i) scanf("%d",&a[i]); sort(a,a+n); k=1; for(i=1;i<n;++i) if(a[i]!=a[i-1]) k++; printf("%d\n%d",k,a[0]); for(i=1;i<n;++i) if(a[i]!=a[i-1]) printf(" %d",a[i]); printf("\n"); } return 0; }
原文:http://blog.csdn.net/qq_18062811/article/details/39213239