-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.cpp
More file actions
161 lines (155 loc) · 4.51 KB
/
Main.cpp
File metadata and controls
161 lines (155 loc) · 4.51 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#include <bits/stdc++.h>
using namespace std;
void string_generator(int n);
int main() {
cout << "RULES OF THE GAME:" << "\n";
cout << " # You have to guess the correct word or phrase with the help of given hints." << "\n";
cout << " # Press ENTER after entering a character." << "\n";
cout << " # Don't enter more than one character at a time." << "\n";
cout << " # You can enter wrong alphabet only three times." << "\n";
cout << " # You either win or you die" << "\n";
cout << "\n";
int i,flag=0,error=0,counter=0;
char t;
int n;
char uds[101];
char ans[101];
int exit=1;
while(exit != 0) {
srand(time(NULL));
n = (rand() % 11 )+ 1;
string_generator(n);
switch(n)
{
case 1 : {
char const *str = "13 REASONS WHY";
strcpy(ans,str);
break;
}
case 2 : {
char const *str = "GAME OF THRONES";
strcpy(ans,str);
break;
}
case 3 : {
char const *str = "ARTHUR CONAN DOYLE";
strcpy(ans,str);
break;
}
case 4 : {
char const *str = "TVF PITCHERS";
strcpy(ans,str);
break;
}
case 5 : {
char const *str = "ELVIS PRESLEY";
strcpy(ans,str);
break;
}
case 6 : {
char const *str = "JOHN LENNON";
strcpy(ans,str);
break;
}
case 7 : {
char const *str = "SOVIET UNION";
strcpy(ans,str);
break;
}
case 8 : {
char const *str = "ARYABHATTA";
strcpy(ans,str);
break;
}
case 9 : {
char const *str = "RETURN OF THE JEDI";
strcpy(ans,str);
break;
}
case 10 : {
char const *str = "GEORGE WASHINGTON";
strcpy(ans,str);
break;
}
case 11 : {
char const *str = "THEODORE ROOSEVELT";
strcpy(ans,str);
break;
}
}
for(i=0;i<101;i++) {
*(uds+i) = '_';
if(*(uds+i) == '_')
flag++;
}
for(i=0;*(ans+i)!='\0';i++) {
if(*(ans+i) == ' ')
*(uds+i) = ' ';
cout << *(uds+i) << " ";
}
cout << "\n";
while(flag != 0) {
cin >> t;
if(t>=97 && t<=122)
t = t-('a'-'A');
counter = 0;
for(i=0;*(ans+i)!='\0';i++) {
if(*(ans+i) == t) {
*(uds+i) = t;
counter++;
}
}
if (counter == 0) {
error++;
if(error==3) {
cout << "Phewh! you lost :-(" << "\n" ;
for(i=0;*(ans+i)!='\0';i++)
cout << *(ans+i);
cout << "\n";
break;
}
else
cout << "Sorry you enterd wrong alphbet." << "\n";
}
flag=0;
for(i=0;*(ans+i)!='\0';i++) {
cout << *(uds+i) << " ";
if(*(uds+i) == '_')
flag++;
}
cout << "\n";
if(flag==0)
cout << "Bravo! you got it." << "\n";
}
cout << "Press 0 to exit ar any other number to play again" << "\n";
cin >> exit;
}
}
void string_generator(int n) {
switch(n)
{
case 1 : cout << "A TV show based on best selling books by J Asher";
break;
case 2 : cout << "A TV show in which nine noble family fight for power, while a forgotten race returns after being dormant for thousand of years";
break;
case 3 : cout << "A TV show based on a detective in early 21st century of London was based on the novels written by a British author whose name was";
break;
case 4 : cout << "A story of trials and tribulations of four young entrepreneurs who quit their day jobs in order to pursue their start up venture";
break;
case 5 : cout << "An American singer aka KING OF ROCK & ROLL who has recorded most number of HOT 100 hits";
break;
case 6 : cout << "An English guitarist, singer, and songwriter who co-founded the Beatles who was murdered while returning to New York with his wife";
break;
case 7 : cout << "With approximately 27 Million total fatalities (both military and civilian), this country lost most lives during World War 2";
break;
case 8 : cout << "The value of zero was first used by this ancient Indian mathematician";
break;
case 9 : cout << "Which Starwars Episode has the codename BLUE HARVEST during it's shooting";
break;
case 10 : cout << "Which American president was an ultra-successful liquor distributor in the new country. He made rye whiskey, apple brandy and peach brandy in his Mount Vernon distillery";
break;
case 11 : cout << "Which American president completed the 90-minute speech with the bullet still lodged in his chest, he told the audience in Milwaukee, I don’t know whether you fully understand that I have just been shot,I give you my word, I do not care a rap about being shot, not a rap.";
break;
}
cout << "\n";
}