VioletaBabel
1181번: 단어 정렬 본문
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
bool compare(const string &a, const string &b)
{
return a.length() < b.length();
}
int main()
{
int n;
string word[20000];
cin >> n;
for (int i = 0; i < n; ++i)
cin >> word[i];
sort(&word[0], &word[n]);
stable_sort(&word[0], &word[n], compare);
cout << word[0] << endl;
for (int i = 1; i < n; ++i)
if(word[i] != word[i-1])
cout << word[i] << endl;
}
'백준 > 백준-C++' 카테고리의 다른 글
10814번: 나이순 정렬 (0) | 2017.06.11 |
---|---|
10825번: 국영수 (0) | 2017.06.11 |
11651번: 좌표 정렬하기 2 (0) | 2017.06.11 |
11650번: 좌표 정렬하기 (0) | 2017.06.11 |
1932번: 숫자삼각형 (0) | 2017.06.10 |
Comments