WOJ1064-What is Left

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;
}*/


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值