-
Notifications
You must be signed in to change notification settings - Fork 0
/
buscaminas2.c
70 lines (63 loc) · 1.09 KB
/
buscaminas2.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
#include <stdio.h>
#include<stdlib.h>
void move(int x,int y,char c, int **m, char **b){
switch (c)
{
case 'd':
if (m[x][y]==-1)
{
b[x][y]='*';
}else{
b[x][y]=m[x][y]+48;
}
break;
case 'b':
b[x][y]='&';
break;
default:
break;
}
}
int main(){
int **m,i,n;
char **b;
scanf("%d",&n);
m=(int**)malloc(sizeof(int*)*n);
m[0]=(int*)malloc(sizeof(int)*n*n);
for(i=1;i<n;i++){
m[i]=m[0]+i*n;
}
b=(char**)malloc(sizeof(char*)*n);
b[0]=(char*)malloc(sizeof(char)*n*n);
for(i=1;i<n;i++){
b[i]=b[0]+i*n;
}
int j;
for(i=0;i<n;i++){
for(j=0;j<n;j++){
scanf("%d",&m[i][j]);
}
}
for(i=0;i<n;i++){
for(j=0;j<n;j++){
b[i][j]='#';
}
}
int nt;
scanf("%d", &nt);
int x, y;
char c;
for ( i = 1; i <=nt; i++)
{
x=y=0;
scanf("%d %d %c", &x, &y, &c);
move(x,y,c,m,b);
}
for(i=0;i<n;i++){
for(j=0;j<n;j++){
printf("%c ", b[i][j]);
}
printf("\n");
}
return 0;
}