class ajedrez
{
public static void main(String arg[])
{
int vertical,horizontal;
String tablero[][]=new String[8][8];
for(int y=0;y<8;y++)
{
if(y%2==0)
{
for(int x=0;x<8;x++)
{
if(x%2==0)
{
tablero[y][x]="B ";
}
if(x%2==1)
{
tablero[y][x]="N ";
}
}
}
if(y%2==1)
{
for(int x=0;x<8;x++)
{
if(x%2==1)
{
tablero[y][x]="B ";
}
if(x%2==0)
{
tablero[y][x]="N ";
}
}
}
}
System.out.println("Su arreglo es el siguiente:");
for(int i=0;i<8;i++)
{
System.out.println();
for(int t=0;t<8;t++)
{
System.out.print(tablero[i][t]);
}
}
System.out.println();
System.out.println();
System.out.println();
System.out.println(" vertical");
System.out.println(" 0 1 2 3 4 5 6 7 ");
System.out.println();
System.out.println("0 B N B N B N B N ");
System.out.println("1 N B N B N B N B");
System.out.println("2 B N B N B N B N ");
System.out.println("3 N B N B N B N B");
System.out.println("4 B N B N B N B N ");
System.out.println("5 N B N B N B N B");
System.out.println("6 B N B N B N B N ");
System.out.println("7 N B N B N B N B");
System.out.println();
System.out.println("Seleccione una posicion de su tablero(coordenadas X,Y):");
horizontal=TextIO.getlnInt();
vertical=TextIO.getlnInt();
//System.out.println(tablero[abcisa-1][ordenada-1]="*");
for(int r=0;r<8;r++)
{
System.out.println();
for(int e=0;e<8;e++)
{
if((r==vertical)&&(e==horizontal))
{
tablero[r][e]="* ";
}
System.out.print(tablero[r][e]);
}
}
System.out.println("Fin");
}
}
ajeds
viernes, 30 de noviembre de 2007 | Publicado por Eliu en 12:39
Etiquetas: programacion
Suscribirse a:
Enviar comentarios (Atom)
0 comentarios:
Publicar un comentario