-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproblema 3.c
572 lines (317 loc) · 11.3 KB
/
problema 3.c
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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
//Jesús Huerta Aguilar, Javier de La Luz Ruiz, Ernesto Flores Cesareo
//Programación I - "Programa: Ahorcado"
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
//PROTOTIPOS
void castig(char []);
void mayus(char *);
void notas(char []);
void life(int);
void xword(int,int,char [],char []);
void duro();
void death(int *,int,char [][20],char []);
void win(int *,int , char []);
void start(char []);
void cont(char *);
void horca(int);
//PRINCIPAL
int main(){
char des,nombre[50];
int tamnom;
do{
castig(nombre);
start(nombre);
cont(&des);
} while (des == 's' || des == 'S');
getch();
return 0;
}
//CONVERTIR A MAYUSCULAS
void mayus(char *word){
int i;
if (*word >= 'a' && *word <= 'z'){
*word -= 32;
}
}
//CASTIGADO
void castig(char nombre[]){
char op,aux[50],aux2[]={"ALGUIEN"};
int error;
do{
error = 0;
printf("%cDesea asignar un nombre al castigado? [S/N] >> ",168);
scanf("%c",&op);
fflush(stdin);
if (op == 's' || op == 'S'){
printf("\nIngrese el nombre: ");
fgets(aux,50,stdin);
aux[strlen(aux)-1]='\0';
strcpy(nombre,aux);
if (strcmp(nombre,"LESKY") == 0){
duro();
}
}
else{
if (op == 'n' || op == 'N'){
strcpy(nombre,aux2);
}
else{
printf("\n[!] ERROR: Ingresa una opci%cn valida [!]",162);
error = 1;
system("cls");
}
}
} while (error == 1);
system("cls");
}
//NOTAS
void notas(char nombre[]){
int i;
printf("\n\t\tPROGRAMACION I\t\t\t - \t\t\tEQUIPO 8");
printf(R"EOF(
________ ___ ___ ________ ________ ________ ________ ________ ________
|\ __ \|\ \|\ \|\ __ \|\ __ \|\ ____\|\ __ \|\ ___ \|\ __ \ %c
\ \ \|\ \ \ \\\ \ \ \|\ \ \ \|\ \ \ \___|\ \ \|\ \ \ \_|\ \ \ \|\ \
\ \ __ \ \ __ \ \ \\\ \ \ _ _\ \ \ \ \ __ \ \ \ \\ \ \ \\\ \
\ \ \ \ \ \ \ \ \ \ \\\ \ \ \\ \\ \ \____\ \ \ \ \ \ \_\\ \ \ \\\ \
\ \__\ \__\ \__\ \__\ \_______\ \__\\ _\\ \_______\ \__\ \__\ \_______\ \_______\
\|__|\|__|\|__|\|__|\|_______|\|__|\|__|\|_______|\|__|\|__|\|_______|\|_______|
)EOF",169);
printf("\n\t\t\t\t SALVA LA VIDA DE %s",nombre);
}
//CONTINUAR?
void cont(char *op){
int error;
do{
error = 0;
printf("%cDesea continuar? [S/N] >> ",168);
scanf("%s",op);
if (*op == 's' || *op == 'S'){
system("cls");
}
else{
if (*op == 'n' || *op == 'N'){
system("cls");
printf("\n\n\t\t\t\tGRACIAS POR USAR NUESTROS SERVICIOS");
printf("\n\n\t\t\t\t EQUIPO 8\t-\tBUAP\n\n");
printf("\t\t\t\t\t POWERED BY:\n");
printf(R"EOF(
/$$$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$$ /$$ /$$$$$$
| $$_____//$$__ $$ /$$__ $$| $$__ $$| $$ /$$__ $$
| $$ | $$ \__/| $$ \__/| $$ \ $$| $$ | $$ \__/
| $$$$$ | $$ | $$ | $$ | $$| $$ | $$ /$$$$
| $$__/ | $$ | $$ | $$ | $$| $$ | $$|_ $$
| $$ | $$ $$| $$ $$| $$ | $$| $$ | $$ \ $$
| $$ | $$$$$$/| $$$$$$/| $$$$$$$/| $$$$$$$$| $$$$$$/
|__/ \______/ \______/ |_______/ |________/ \______/
)EOF");
}
else{
printf("\n\t[!] ERROR: Ingresa una opci%cn valida [!]\n\n\t",162);
error = 1;
}
}
} while (error == 1);
}
//VIDAS
void life(int try){
int i;
printf("\n\n\tVIDAS [%d] ",7-try);
for (i = 0; i < 7-try; i++){
printf("%c",03);
printf(" ");
}
}
//PALABRA DESCIFRADA
void xword(int tam,int try,char cens[],char nombre[]){
int i;
printf("\t\t\t\t\t");
for (i = 0; i < try+1; i++){//ESPACIOS
printf(" ");
}
printf("%c ",16);
for (i = 0; i < tam; i++){
printf("%c",cens[i]);
printf(" ");
}
//AVISO ULTIMO INTENTO
printf("%c",17);
if (try == 6){
printf("\n\n\t [!] ES TU ULTIMO INTENTO, LA VIDA DE %s ESTA EN TUS MANOS [!]",nombre);
}
}
//MUERTE
void death(int *try,int act,char word[][20],char nombre[]){
if (*try == 7){
printf("\n\n\n\t\t\t\t [!] %s HA MUERTO [!]",nombre);
printf("\n\t\t\t\tLA RESPUESTA ERA: %s",word[act]);
printf("\n\n\n\t");
*try = 8;
}
}
//VICTORIA
void win(int *try,int tam, char cens[]){
int i,x;
x = 0;
for (i = 0; i <tam; i++){
if (cens[i] == 'X'){
x++;
}
}
if (x == 0){
printf("\n\n\n\t\t\t%c%c %cFELICIDADES! USTED PUDO ADIVINAR MI PALABRA %c%c",205,205,173,205,205);
printf("\n\n\t\t\t\t ");
*try = 8;
}
}
//INICIO
void start(char nombre[]){
char word[10][20] = {"AMLO","LUIS","PROGRAMADORESE3","MEMELAS","MOMERO","ESTRADA","WATSAP2","FCCDLG","PAPU","SDLG"};
int act,tam,i,correct,try=0;
char letra,x;
srand(time(NULL));
act = rand() % 10;
tam = strlen(word[act]);
char cens[tam];
//COLOCAR X
for (i = 0; i < tam; i++){
cens[i] = 'X';
}
do{
system("cls");
correct = 0;
notas(nombre);
//DIBUJO
horca(try);
printf("\n\n");
//Separador
printf(" ");
for (i = 0; i < 95; i++){
printf("%c",205);
}
//VIDAS
life(try);
//Palabra desifrada
xword(tam,try,cens,nombre);
//MUERTE
death(&try,act,word,nombre);
//VICTORIA
win(&try,tam,cens);
//ENTRADA DE LETRAS
if (try < 8){
printf("\n\n\tINGRESE UNA LETRA: ");
scanf(" %c",&letra);
mayus(&letra);
for (i = 0; i < tam; i++){
if (letra == word[act][i]){
cens[i] = letra;
correct++;
}
}
if (correct == 0){
try++;
}
}
} while (try < 8);
}
//DIBUJO HORCA
void horca(int try){
switch(try){
case 0:
printf("\n\t\t\t\t\t _______\n\t\t\t\t\t | |\n\t\t\t\t\t |\n\t\t\t\t\t |\n\t\t\t\t\t |\n\t\t\t\t\t |\n\t\t\t\t\t |\n\t\t\t\t\t ----------");
break;
case 1:
printf("\n\t\t\t\t\t _______\n\t\t\t\t\t | |\n\t\t\t\t\t | 0\n\t\t\t\t\t |\n\t\t\t\t\t |\n\t\t\t\t\t |\n\t\t\t\t\t |\n\t\t\t\t\t ----------");
break;
case 2:
printf("\n\t\t\t\t\t _______\n\t\t\t\t\t | |\n\t\t\t\t\t | 0\n\t\t\t\t\t | |\n\t\t\t\t\t |\n\t\t\t\t\t |\n\t\t\t\t\t |\n\t\t\t\t\t ----------");
break;
case 3:
printf("\n\t\t\t\t\t _______\n\t\t\t\t\t | |\n\t\t\t\t\t | 0\n\t\t\t\t\t | /|\n\t\t\t\t\t |\n\t\t\t\t\t |\n\t\t\t\t\t |\n\t\t\t\t\t ----------");
break;
case 4:
printf("\n\t\t\t\t\t _______\n\t\t\t\t\t | |\n\t\t\t\t\t | 0\n\t\t\t\t\t | /|");
printf("\\");
printf("\n\t\t\t\t\t");
printf(" |\n\t\t\t\t\t |\n\t\t\t\t\t |\n\t\t\t\t\t ----------");
break;
case 5:
printf("\n\t\t\t\t\t _______\n\t\t\t\t\t | |\n\t\t\t\t\t | 0\n\t\t\t\t\t | /|");
printf("\\");
printf("\n\t\t\t\t\t");
printf(" | |\n\t\t\t\t\t |\n\t\t\t\t\t |\n\t\t\t\t\t ----------");
break;
case 6:
printf("\n\t\t\t\t\t _______\n\t\t\t\t\t | |\n\t\t\t\t\t | 0\n\t\t\t\t\t | /|");
printf("\\");
printf("\n\t\t\t\t\t");
printf(" | |\n\t\t\t\t\t |");
printf(" /\n\t\t\t\t\t |\n\t\t\t\t\t ----------");
break;
case 7:
printf("\n\t\t\t\t\t _______\n\t\t\t\t\t | |\n\t\t\t\t\t | 0\n\t\t\t\t\t | /|");
printf("\\");
printf("\n\t\t\t\t\t");
printf(" | |");
printf("\n\t\t\t\t\t");
printf(" | / ");
printf("\\");
printf("\n\t\t\t\t\t");
printf(" |\n\t\t\t\t\t ----------");
break;
}
}
//EASTER EGG
void duro(){
system("cls");
printf(R"EOF(
llllllllllllllllllllllc:;,,''''',,;:ccllllllllllllllllllllll
llllllllllllllllllc;'.. ...,:cllllllllllllllllll
llllllllllllllll:'. .,:llllllllllllllll
llllllllllllll;. .':llllllllllllll
llllllllllll:. .:llllllllllll
llllllllll:. ............ .'cllllllllol
lllllllll:. ....',,,''..,;:ccccccc:;,'... .clllllllol
llllllll:. ...',;;::ccccclloooooooolcc:;,'.. .collllllo
lllllllc. ....',;;:ccllllooooddxxxddollc:;;,.. ,lolllloo
lllllll; .....',,;:ccllllooooodxxxxddollc::;;,. .:olllool
lllllll. .....',,;;:cclloddddddxxxxddollc:::;,. 'lllooll
llllllc. ....'',;;:clodddxxxxxxxxkkkxdollc::;;'. .coloool
llllll:. .....',;;:cloddxkkkkkkkkkkkkkdoc:;;,,;,.. .:olloll
llllllc. ............';ldxxkkkkkkdl:;''........,,. .colllll
llllllc. ... ......',;coodxxxxdoc:::::cc:;,'..,' .lolllll
llllllc. .. ..,:llooollc::codxxdoooooodxxxddol:,,,..:llllll
llllll:......',,;:cooooooc;,cdkxdooooc:::c::c:::::,..':lllll
llllll:.............';c:ll;':dxxdoodc;,.......',::;'',clllll
lllllll'.........'',:loloc,,:oddoolooc:::ccc:;;:cc;'':llllll
lllllll,...',,;;:cloooool;,,:looolloddddoooooollcc:,,:llllll
lllllll,...',:loddddddooc,,,;cooollloxkkxxddddddolc,,cllllll
lllllll;...';:lodddxxxoc;''';cllolccoxkkkxxxxxxxdoc;:lolllll
lllllll:. ..,:codxkkkko;...,:looooc::lxxkkkOOOkxdoc::lolllll
lllllllc. ..,:loxkOOkd:..'':lodxkxocccoddxkOOOkxdoc;:lllllll
llllllll,...,cldxkkkxl,.,;,:ldxxkxoc:ldxoodxkxxdol:;collllll
llllllll:. .':cloddocc:,,''';:cclllccoddolloddoolc;:lollllll
lllllllll, ..';:c:;,,,,,,',;:ccllooolllolc::lllcc;;cllllllll
lllllllllc' ..,::,''..',,,,;cccccllcccccc:::clcc:;:lllllllll
llllllllllc...';cc:,'.......',;;;;,,,,,:c:cllc::;:llllllllll
lllllllllll:...';c:;''.....,;:::::;,,,:lc:cc:;;;clllllllllll
llllc:;,''... ...'''''''.',;clcc:;;:clc:;;;,,,:llllllllllll
;,'... .. ...'''''',,,;;::ccccc::;;,,,,,,,;:clllllll
.... .. .',,,,,,,;;;;:c:::::;,',;;,''......';:cc
.... .... .',,,;::cclllc::::,',;;:;,'',,,,. ..
.... ...... ..',,,;:::ccc:;;'';::::;;,,;;;:;.
.... ....... ......',,,,''',;:ccc::;;,;:ccl:.
.... ................'',;:cccccc::::::cllo;.
..................'',,;;:ccclllccc:::ccclooc.
.',''.......''''',,,;;;:ccllllccccccclooo:.
.,::;,'..',,;,,,;;;:::ccllllccccclllodl,
.;llc:;;:ccc:::::::cclllllclllooooc,.
.';:ccloooollllllloooolloooooc,.
..',:cclllooooooollc:;,.. .............
.......... .............
)EOF");
getch();
}