Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Arrays;
- public class tablerobeta
- {
- public static void main(String[] args)
- {
- int filas =5;
- int columas =8;
- int [][] tablero = new int [columas][filas];
- //GENERA LOS DATOS DEL TABLERO//
- for (int i=0; i<columas ; i++) {
- for (int j=0; j<filas ; j++) {
- tablero[i][j] = (char) (Math.random()*3+97);
- }
- }
- //GENERA LOS * DE ARRIBA//
- for (int i=0; i<columas*4+4 ; i++) {
- System.out.print("*");
- }
- System.out.println(" ");
- //GENERA LOS * ENTRE LAS FILAS Y LA LINEA DE * *//
- for (int j=0; j<filas ; j++){
- if (j!=0){
- System.out.println (" ");
- }
- System.out.print("*");
- for (int i=0; i<columas*4+4-2; i++) {
- System.out.print(" ");
- }
- System.out.print("*");
- System.out.println (" ");
- for (int i=0; i<=columas ; i++){
- if (i==0 ){
- System.out.print ( "* ");
- System.out.printf (" %c ",tablero[i][j] );
- System.out.print (" ");
- }else if ( i==columas){
- System.out.print ( "* " );
- }else {
- System.out.printf (" %c ",tablero[i][j] );
- System.out.print (" ");
- }
- }
- }
- System.out.println(" ");
- //System.out.print ("* *");
- System.out.print("*");
- for (int i=0; i<columas*4+4-2; i++) {
- System.out.print(" ");
- }
- System.out.print("*");
- System.out.println(" ");
- //GENERA LINEA DE **//
- for (int i=0; i<columas*4+4 ; i++) {
- System.out.print("*");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement