Arreglos bidimensionales???
Necesito ayuda con un ejercicio acerca de arreglos bidimensionales, necesito que en la pantalla me aparezca algo como:
8888888
8000000
8888800
8000000
8888888
8888888
8000000
8888800
8000000
8888888
Salu2!
Si aun no tienes los valores en el arreglo puedes intentar esto:
int array[][] = {{8,8,8,8,8,8,8}, {8,0,0,0,0,0,0}, {8,8,8,8,8,0,0}, {8,0,0,0,0,0,0}, {8,8,8,8,8,8,8,8} };
y lo imprimes asi:
for (int i=0; i<array.length; i++)
for (int j=0; j<array[i].length; j++)
if (j+1 == array[i].length)
System.out.println(Integer.toString(array[i][j]));
else
System.out.print(Integer.toString(array[i][j]));
espero te sea util... chau!
Si aun no tienes los valores en el arreglo puedes intentar esto:
int array[][] = {{8,8,8,8,8,8,8}, {8,0,0,0,0,0,0}, {8,8,8,8,8,0,0}, {8,0,0,0,0,0,0}, {8,8,8,8,8,8,8,8} };
y lo imprimes asi:
for (int i=0; i<array.length; i++)
for (int j=0; j<array[i].length; j++)
if (j+1 == array[i].length)
System.out.println(Integer.toString(array[i][j]));
else
System.out.print(Integer.toString(array[i][j]));
espero te sea util... chau!
