-
Notifications
You must be signed in to change notification settings - Fork 0
/
baekjoon1759.cpp
69 lines (62 loc) · 1.46 KB
/
baekjoon1759.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <iostream>
#include <algorithm>
using namespace std;
char alpha[16] = {0};
char new_alpha[16] = {0};
int count_vowel(int n) {
int count = 0;
for (int i = 0; i < n; i++) {
if (new_alpha[i] == 'a' ||new_alpha[i] == 'e'|| new_alpha[i] == 'i' || new_alpha[i] == 'o' || new_alpha[i] == 'u') {
count++;
}
}
return count;
}
int count_consonant(int n) {
int count = 0;
for (int i = 0; i < n; i++) {
if (new_alpha[i] != 'a'&& new_alpha[i] != 'e' && new_alpha[i] != 'i' && new_alpha[i] != 'o' && new_alpha[i] != 'u') {
count++;
}
}
return count;
}
int check_arr(int n) {
if (n == 0)
return 1;
for (int i = 0; i < n; i++) {
if (new_alpha[n] <= new_alpha[i])
return 0;
}
return 1;
}
void put_alpha(int m, int n, int k) {
if (n == k) {
if (count_vowel(k) == 0 || count_consonant(k) < 2) {
return;
}
else {
for (int i = 0; i < k; i++) {
cout << new_alpha[i];
}
cout << '\n';
}
}
else {
for (int i = 0; i < m; i++) {
new_alpha[n] = alpha[i];
if (check_arr(n)) {
put_alpha(m, n + 1, k);
}
}
}
}
int main(void) {
int L, C;
cin >> L >> C;
for (int i = 0; i < C; i++) {
cin >> alpha[i];
}
sort(alpha, alpha+C);
put_alpha(C, 0, L);
}