-
Notifications
You must be signed in to change notification settings - Fork 1
/
ayuda2.c
executable file
·51 lines (46 loc) · 983 Bytes
/
ayuda2.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
/*
** Programa para substituir aleatoriamente mosaicos 1 por 56
** (solo para usarse una vez por mapa)
**
** por Oscar Toledo Guti‚rrez
**
** (c) Copyright 2011 Oscar Toledo Guti‚rrez
**
** Creaci¢n: 06-abr-2011.
*/
#include <stdio.h>
#include <string.h>
char lineas[1024][80];
/*
** Programa principal
*/
int main(void)
{
int linea = 0;
int max_linea = 0;
char *ap;
int c;
srand(time(0));
while (fgets(lineas[max_linea], 79, stdin))
max_linea++;
while (memcmp(lineas[linea], "mapa", 4) != 0)
linea++;
while (linea < max_linea) {
ap = lineas[linea];
while (*ap) {
if (memcmp(ap, "01", 2) == 0) {
c = rand();
if ((c & 15) == 0) {
if ((c & 16) == 0)
memcpy(ap, "56", 2);
else
memcpy(ap, "57", 2);
}
}
ap++;
}
linea++;
}
for (linea = 0; linea < max_linea; linea++)
printf("%s", lineas[linea]);
}