Basic Modifications - Unique

583 词

题目描述

Unique For a sequence of integers A={a0,a1,…,an−1} which is sorted by ascending order, eliminate all equivalent elements.

输入

A sequence is given in the following format.

a0 a1,…,an−1

输出

Print the sequence after eliminating equivalent elements in a line. Separate adjacency elements by a space character.

样例输入

1
2
4
1 2 2 4

样例输出

1
1 2 4

提示

1≤n≤100,000 

−1000,000,000≤ai≤1,000,000,000 

a0≤a1≤…≤an−1

题解

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <set>
#include <iostream>
using namespace std;
int main(){
int n;cin>>n;
set<int> s;
while(n--){
int t;
cin>>t;
s.insert(t);
}
for(int i:s)
{
printf("%d ",i);
}
}