forked from rohitthapliyal2000/Competitive-Algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStringsGeneration-AlternateVowels.cpp
61 lines (57 loc) · 1.53 KB
/
StringsGeneration-AlternateVowels.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
#include <bits/stdc++.h>
#include<stdio.h>
using namespace std;
char arr[10];
int check;
int counter = 0;
int n;
void generate(int counter)
{
if(counter==n)
{
printf("%s",arr);
cout << endl;
}
else
if( counter == 0 )
{
for(int i = 97 ; i <= 122; i++)
{
if(i == 121 )
continue;
arr[counter] = i;
generate(counter+1);
}
}
else if(arr[counter-1] == 'i' || arr[counter-1] == 'a' || arr[counter-1] == 'e' || arr[counter-1] == 'o' || arr[counter-1] == 'u')
{
for(int k = 97 ; k <= 122; k++)
{
if( k != 97 && k != 101 && k != 105 && k != 121 && k != 111 && k != 117)
{
arr[counter] = k;
generate(counter+1);
}
}
}
else
{
for(int l = 97; l <= 122; l++)
{
if(l == 97 || l == 101 || l == 105 || l == 111 || l == 117)
{
arr[counter] = l;
generate(counter+1);
}
else
continue;
}
}
}
int main()
{
cin >> n;
check = n;
generate(counter);
return 0;
}