-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
79 lines (60 loc) · 1.17 KB
/
main.cpp
File metadata and controls
79 lines (60 loc) · 1.17 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
/*fase de prueba para un codigo de generacion de escenarios 2D aleatorios, evitando colisiones
entre objetos, sabiendo su tamaño. Version para una matriz de diez elementos. al final está
pensado generar las coordenadas de cada objeto de forma aleatoria, pero para provar fallos, se meten a mano ahora.
Los objetos colocados en esta version son de 2x2 elementos.*/
#include <stdio.h>
#include <stdlib.h>
void pobjeto(int matriz[][10]){
int x,y;
while(true)
{
int ref=0;
printf("Introduzca las coordenadas del objeto:");
scanf("%d",&x);
scanf("%d",&y);
for(int i=x;i<x+2;i++)
{
for(int j=y;j<y+2;j++)
{
if(matriz[i][j]==1)
ref++;
}
}
if (ref!=0){
printf("Posicion no valida");
}
else
{
for(int i=x;i<x+2;i++)
{
for(int j=y;j<y+2;j++)
matriz[i][j]=1;
}
for( int i=0;i<10;i++)
{
printf("\n");
for( int j=0;j<10;j++)
printf("%d",matriz[i][j]);
}
}
}
}
int main( ){
const int a=10,b=10;
int i=0,j=0;
int matriz[10][10];
for( i=0;i<a;i++)
{
for( j=0;j<b;j++)
matriz[i][j]=0;
}
for( i=0;i<a;i++)
{
printf("\n");
for( j=0;j<b;j++)
printf("%d",matriz[i][j]);
}
printf("\n");
pobjeto(matriz);
system("PAUSE");
}