-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlevel 2
More file actions
265 lines (225 loc) · 6.22 KB
/
level 2
File metadata and controls
265 lines (225 loc) · 6.22 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
#include <iostream.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <ctype.h>
#include <math.h>
#include <iomanip.h>
#include <time.h>
#include <string.h>
#define br getch();
void main()
{
clrscr();
//**********************************************************
time_t timer;
struct tm y2k = {0};
double seconds;
y2k.tm_hour = 0; y2k.tm_min = 0; y2k.tm_sec = 0;
y2k.tm_year = 100; y2k.tm_mon = 0; y2k.tm_mday = 1;
time(&timer); /* get current time; same as: timer = time(NULL) */
seconds = difftime(timer,mktime(&y2k));
//**********************************************************
cout<<" *** CyberBuzz 2k18 : Programming *** "<<endl; br
//*****************************
cout<<" ** Level 2 **"<<endl; br
double timeout,points;
char first[30];
cout<<endl<<"Call any volunteer/head to proceed ";
cin>>points;
cout<<endl<<endl<<"Second round is special as in you can use your prelims points here!";
cout<<endl<<"You have "<<points<<" Points! Best of Luck!"; br
clrscr();
cout<<endl<<"Your first question:- "<<endl;
cout<<"There IS HUGE Penalty for wrong answer in this question"<<endl;
cout<<"Find the number of errors of the following question and enter the answer"<<endl;
// *** Question 1
cout<<endl<<"void main() { int j,temp,Marks[] = { 99, 92, 94, 96, 93, 95 }, cb[6]; ";
cout<<endl<<"for(int i=0;i<6;i++) { if(i-3<0) cb[i] = Marks[1 + random(2)]; ";
cout<<endl<<"else cb[i]=(rand()%10)*i; }";
cout<<endl<<"for(i=0;i<6;i++) {cin>>cb[i]; }";
cout<<endl<<"for(int i=1;i<=5;i++) {temp=cb[i]; j=i-1;";
cout<<endl<<"while((temp<a[j])&&(j>=0)) {cb[j+1]=cb[j]; j=j-1; } ";
cout<<endl<<"cb[j+1]=temp; }";
cout<<endl<<"for(int k=0;k<6;k++) {cout<<cb[k]; }} ";
// ***
cout<<endl<<endl<<"Which sorting code is used above ? ";
cout<<endl<<"1. Bubble 2. Selection 3. Insertion";
cout<<endl;
a:
cout<<"Type the answer: ";
gets(first);
char skip_p;
// *** Answer 1
if ((strcmp(first,"insertion")==0)||(strcmp(first,"Insertion")==0)||(strcmp(first,"3")==0))
// ***
// ***
cout<<"Correct!"<<endl;
else
{
cout<<"Wrong Answer!"<<endl;
if(points>=35)
{
cout<<"Enter p to use 35 points and continue or anything else to wait 6 mins ";
cin>>skip_p;
if ((skip_p == 'p') || (skip_p == 'P'))
{
points -= 35;
goto r;
}
}
cout<<"You have been locked out for 6 minutes!"<<endl;
time(&timer);
seconds = difftime(timer,mktime(&y2k));
timeout=seconds+360;
while(seconds<timeout)
{
time(&timer);
seconds = difftime(timer,mktime(&y2k));
}
cout<<endl<<"6 minutes have elapsed!"<<endl; br
goto a;
}
// ******************************
r:
clrscr();
char sec_w_op;
int sec_w_op_check=0,gamble2;
cout<<endl<<"Your second question:- "<<endl;
cout<<"This question allows you to wager your points, would you like to wager some? (y-yes/n-no) ";
cin>>sec_w_op;
if(sec_w_op=='y')
{
sec_w_op_check=1;
cout<<endl<<"Cool, you have "<<points<<", enter your gamble amount ";
cin>>gamble2;
}
cout<<endl;
cout<<endl<<"Which is better for storing passwords?"<<endl;
cout<<"(a-char array, b-char string)"<<endl;
char resp_3;
cout<<"Type the answer: ";
cin>>resp_3;
// *** Answer 3
if (resp_3=='a')
// ***
{
cout<<"Correct!"<<endl;
if(sec_w_op_check==1)
{
points+=gamble2;
cout<<endl<<"Your points have increased by "<<gamble2<<", New amount= "<<points; br
}
}
else
{
cout<<endl<<"Wrong Answer";
if(sec_w_op_check==1)
{
cout<<endl<<"You lose "<<gamble2<<" points!";
points-=gamble2;
}
else
{
cout << endl << "Since you didn't bet anything and its a wrong answer, so.... wait 5 mins!!" << endl;
time(&timer);
seconds = difftime(timer, mktime(&y2k));
timeout = seconds + 300;
while (seconds<timeout)
{
time(&timer);
seconds = difftime(timer, mktime(&y2k));
}
cout << endl << "5 minutes have elapsed!" << endl;
}
}
br
char resp2,resp2_2[20];
clrscr();
cout<<endl<<"Your third question is an ALL IN round, double or lose your points!"<<endl;
// *** Question 3
cout<<" However, if you choose not to attempt this question, you still lose half your"<<endl<<"points :P"<<endl;
// ***
cout<<"Would you like to attempt? (y-yes/n-no)"<<endl;
cout<<"Type the answer: ";
cin>>resp2;
if (resp2=='y')
{
cout<<"Yeah! Find out the output and call a volunteer to answer"<<endl;
cout<<endl<<"void main() {int a=0,b=1;";
cout<<endl<<"int f; n=20;";
cout<<endl<<"for(int d=0;d<3;d++) { cout<<\" \";";
cout<<endl<<"for(int j=0;j<d;j++) {";
cout<<endl<<"for(int k=0;k<2*d;k++) {cout<<\"*\";";
cout<<endl<<"cout<<a<<b; cout<<\"desi shopkeepers\";";
cout<<endl<<"while(b>0) cout<<n; }";
cout<<endl<<"cout<<\"cyberbuzz\"; }}";
cout<<endl<<"getch(); } ";
cout<<"Call event head/member ";
gets(resp2_2);
if((strcmp(resp2_2,"congratz")==0)||(strcmp(resp2_2,"pokemon")==0)||(strcmp(resp2_2,"bitcoin")==0))
{
cout<<endl<<"Correct! :P You double your points!"<<endl;
points*=2;
}
else
{
cout<<endl<<"Woops! You lose all your points :(";
cout<<endl;
points=0;
}
}
else
{
cout<<endl<<"Hmmm..... You lose half your points!"<<endl;
points/=2;
}
// *************
br
clrscr();
cout<<"LAST one :P Next level will be final!"<<endl; br
cout<<"No gamble here :("<<endl<<endl; br
if(points>=40)
{
cout<<"You CAN USE 40 points to skip this level ;)"<<endl; br
cout<<"You can skip anytime by entering 'skip' when asked for answer"<<endl<<endl; br
}
//*******************************************
cout<<"int h=8; void Main(int a,int b) {for(int i=0;i<=3;i++) {"<<endl;
cout<<"if(i%2==0) cout<<(char)(a+67);"<<endl;
cout<<"else cout<<b; }}\";"<<endl;
cout<<"void Main(int &c,char d) { {Main(c,2); "<<endl;
cout<<"cout<<(char)(d+3); }}"<<endl;
cout<<"void main() {"<<endl;
cout<<"int h=5,i=9; char j='E'; "<<endl;
cout<<"Main(i,j); Main(h,i); }"<<endl;
char resp_4[40];
e:
cout<<"Type the answer: ";
gets(resp_4);
// *** Answer 1
if ((strcmp(resp_4,"L2L2HH9H9")==0)||((strcmp(resp_4,"skip")==0)&&(points>=40)))
// ***
{
cout<<"Yess!"<<endl; br
if ((strcmp(resp_4,"skip")==0))
points-=40;
}
else
{
goto e;
}
char check_r2[20];
p:
cout<<"Call any volunteer/event head to continue ";
gets(check_r2);
if(strcmp(check_r2,"balance")==0)
{
cout<<"The balance for this team is "<<points; br
cout<<endl<<endl<<"Now we will print the password for next file, make sure others don't see it"<<endl<<"PRESS ENTER"<<endl; br
cout<<"thelevelhasnotended";
}
else
goto p;
br
}