vector<int> sorted;
for (int i=0; i<n; i++){
int tmp;
cin>>tmp;
sorted.push_back(tmp);
}
sort(sorted.begin(), sorted.end());
sorted.erase(unique(sorted.begin(), sorted.end()), sorted.end());
vector<int> sorted;
int n;
cin>>n;
for (int i=0; i<n; i++)
{
int tmp;
cin>>tmp;
sorted.push_back(tmp);
}
sort(sorted.begin(), sorted.end());
for (int i=0; i<n; i++){
cout << sorted[i] << ' ';
}
cout<<endl;
unique(sorted.begin(), sorted.end());
for (int i=0; i<n; i++){
cout << sorted[i] << ' ';
}
cout<<endl;
결과)
입력 : 7
출력 :
1 4 2 3 2 1 1
1 1 1 2 2 3 4
1 2 3 4 2 3 4