1245:不重复地输出数
时间限制: 1000 ms 内存限制: 65536 KB
【题目描述】
输入n个数,从小到大将它们输出,重复的数只输出一次。保证不同的数不超过500个。
【输入】
第一行是一个整数n。1 ≤ n ≤ 100000。
之后n行,每行一个整数。整数大小在int范围内。
【输出】
一行,从小到大不重复地输出这些数,相邻两个数之间用单个空格隔开。
【输入样例】
5
2 4 4 5 1
【输出样例】
1 2 4 5
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <limits.h>
#include <map>
using namespace std;
int n,t;
map<int,int> a;
int main(int argc, char *argv[])
{
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%d",&t);
a[t]++;
}
map<int,int>::iterator it;
for(it=a.begin();it!=a.end();it++){
cout<<it->first<<" ";
}
return 0;
}