-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen.h
56 lines (50 loc) · 1.22 KB
/
gen.h
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
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <string>
#include <ctime>
#include <algorithm>
using namespace std;
string cons = "BBCCDDDDFFGGGHHJKLLLLMMNNNNNNPPQRRRRRRSSSSTTTTTTVVWWXYYZ";
string vowel= "AAAAAAAAAEEEEEEEEEEEEIIIIIIIIIOOOOOOOOUUUU";
string gen= "999999999";
int input;
int cnt,conscnt,vowelcnt;
void gencons(int& cnt) {
srand((time(NULL))*(cnt+1));
gen[cnt] = cons[abs(rand()) % (cons.length())];
cout << gen[cnt] << endl;
conscnt++;
cnt++;
}
void genvowel(int& cnt) {
srand((time(NULL))*(cnt+1));
gen[cnt] = vowel[abs(rand()) % (vowel.length())];
cout << gen[cnt] << endl;
vowelcnt++;
cnt++;
}
void genm() {
printf ("Press 0 to generate a consonant and press 1 to generate a vowel \n");
printf ("There are nine letters for the countdown game. \n");
cnt=0;
conscnt=0;
vowelcnt=0;
for (cnt=0; cnt<= 8;){
if (conscnt==6) {
genvowel(cnt);
}
else if (vowelcnt==5) {
gencons(cnt);
}
else {
printf ("Letter number %d:", cnt+1);
cin >> input;
if (input == 0) gencons(cnt);
else if (input == 1) genvowel(cnt);
else continue;
}
}
printf ("\n");
cout << "The nine shuffled letters are: " << gen << endl;
}