赞
踩
1 10 20 40 32 67 40 20 89 300 400 15
8 15 20 32 40 67 89 300 400
AC代码:
- #include<stdio.h>
- #include<algorithm>
- using namespace std;
- int main()
- {
- int n,m,a[200],i,s;
-
- while(scanf("%d",&n)!=EOF)
- {
- while(n--)
- {
- scanf("%d",&m);
- s=m;
- for(i=0;i<m;i++)
- scanf("%d",a+i);
- sort(a,a+m);
- for(i=0;i<m;i++)
- {
- if(a[i]==a[i+1])s--;
- }
- printf("%d\n",s);
- unique(a,a+m);
- for(i=0;i<s;i++)
- {
- if(i==0)
- printf("%d",a[i]);
- else printf(" %d",a[i]);
- }
- printf("\n");
- }
- }
- return 0;
- }
-
- #include<iostream>
- #include<map>
- #include<cstdio>
- #include<algorithm>
- #include<iterator>
- using namespace std;
- const int maxn=110;
- int tab[maxn];
- int main()
- {
-
- int t;cin>>t;
- while(t--){
- int n;cin>>n;
- for(int i=0;i<n;i++)scanf("%d",&tab[i]);
- sort(tab,tab+n);
- cout<<(n=distance(tab,unique(tab,tab+n)))<<endl;
- copy(tab,tab+n,ostream_iterator<int>(cout," "));cout<<endl;
- }
-
- }
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。