Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. import java.util.Arrays;
  2. public class tablerobeta
  3. {
  4. public static void main(String[] args)
  5. {
  6. int filas =5;
  7. int columas =8;
  8. int [][] tablero = new int [columas][filas];
  9. //GENERA LOS DATOS DEL TABLERO//
  10. for (int i=0; i<columas ; i++) {
  11. for (int j=0; j<filas ; j++) {
  12. tablero[i][j] = (char) (Math.random()*3+97);
  13. }
  14. }
  15. //GENERA LOS * DE ARRIBA//
  16. for (int i=0; i<columas*4+4 ; i++) {
  17. System.out.print("*");
  18. }
  19. System.out.println(" ");
  20. //GENERA LOS * ENTRE LAS FILAS Y LA LINEA DE * *//
  21.  
  22. for (int j=0; j<filas ; j++){
  23.  
  24. if (j!=0){
  25. System.out.println (" ");
  26. }
  27.  
  28. System.out.print("*");
  29. for (int i=0; i<columas*4+4-2; i++) {
  30. System.out.print(" ");
  31. }
  32. System.out.print("*");
  33. System.out.println (" ");
  34.  
  35. for (int i=0; i<=columas ; i++){
  36.  
  37. if (i==0 ){
  38.  
  39. System.out.print ( "* ");
  40. System.out.printf (" %c ",tablero[i][j] );
  41. System.out.print (" ");
  42. }else if ( i==columas){
  43. System.out.print ( "* " );
  44. }else {
  45.  
  46. System.out.printf (" %c ",tablero[i][j] );
  47. System.out.print (" ");
  48. }
  49. }
  50.  
  51. }
  52.  
  53. System.out.println(" ");
  54. //System.out.print ("* *");
  55. System.out.print("*");
  56. for (int i=0; i<columas*4+4-2; i++) {
  57. System.out.print(" ");
  58. }
  59. System.out.print("*");
  60. System.out.println(" ");
  61.  
  62. //GENERA LINEA DE **//
  63. for (int i=0; i<columas*4+4 ; i++) {
  64. System.out.print("*");
  65. }
  66.  
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement