백준 1181 c++
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int input(int lower, int upper);
void input_word(string* word, int size);
void sort_word(string* word, int size);
void print_word(string* word, int size);
bool compare(string front, string back);
int main(void)
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int N;
int i;
string* word;
N = input(1, 20000);
word = new string[N];
input_word(word, N);
sort_word(word, N);
print_word(word, N);
delete[] word;
return 0;
}
int input(int lower, int upper)
{
int A;
while (1)
{
cin >> A;
if (A >= lower && A <= upper)
{
break;
}
else
{
;
}
}
return A;
}
void input_word(string *word, int size)
{
int i;
for (i = 0; i < size; i++)
{
cin >> word[i];
}
return;
}
void sort_word(string *word, int size)
{
sort(word, word + size, compare);
return;
}
void print_word(string* word, int size)
{
int i;
for (i = 0; i < size; i++)
{
if (word[i] == word[i + 1])
{
;
}
else
{
cout << word[i] << '\n';
}
}
return;
}
bool compare(string front, string back)
{
if (front.length() == back.length())
{
return front < back;
}
else
{
return front.length() < back.length();
}
}