My lovely sister QingQing has many books. One day she numbers her books with integer. Of cause same books are marked by
the same number. When all the books are marked, it is easy to find how many are the same. :-)
Now QingQing has a list of books( given by numbers they are marked). In order to buy a gift for her dear brother, she plans to sell some books. But she wants to keep one copy for each kind. After selling, what books is left?
Please write a program to tell QingQing the answer.
输入格式
First line is an number N(1<=N<=50000), meaning the books that QingQing has before selling.
Next line will contain N numbers, the marks of the books, separated by a single space.(the marks are between 0 and 999, inclusively)
输出格式
A line for each test case contains the marks of the books after selling.(sorted in non-descending order).
Two numbers are separated by a single space.
样例输入
5 1 2 5 4 5 2 1 2
样例输出
1 2 4 5 1 2
#include<stdio.h>
#include<string.h>
int sh[1000];
int main(){
int n,i,t,s;
while(scanf("%d",&n)!=EOF){
memset(sh,0,sizeof(sh));
s=1;
for(i=0;i<n;i++){
scanf("%d",&t);
sh[t]=1;
}
for(i=0;i<1000;i++)
if(sh[i]==1){
if(s){
printf("%d",i);
s=0;
}
else
printf(" %d",i);
}
printf("\n");
}
return 0;
}
/* #include<cstdio> #include<algorithm> using namespace std; int shu[50005]; int main(){ int n,i,t; while(scanf("%d",&n)!=EOF){ for(i=0;i<n;i++) scanf("%d",&shu[i]); sort(shu,shu+n); t=shu[0]; printf("%d",t); for(i=1;i<n;i++) if(t!=shu[i]){ t=shu[i]; printf(" %d",t); } printf("\n"); } return 0; }*/