Advertisement
cgorrillaha

Untitled

Jan 25th, 2022
1,112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.41 KB | None | 0 0
  1. public class TooDeez {
  2.     public static void main(String[] args) {
  3.         int[][] arr=new int[5][5];
  4.         int[][] grid={{1,2,3,4,5,6,7,8},
  5.                       {2,3,4,5,6,7,8,9},
  6.                       {3,4,5,6,7,8,9,0},
  7.                       {0,9,8,7,6,5,4,3},
  8.                       {4,3,2,5,6,7,3,9},
  9.                       {4,5,6,1,4,8,9,0},
  10.                       {3,2,1,5,6,7,8,9},
  11.                       {3,2,5,6,7,1,2,7}
  12.         };
  13.         int[]nums={1,2,3,4,5,6,7,8,9,0};
  14.  
  15.         arr[3][4]=5;
  16.         int n=arr[1][2];
  17.         grid[1][1]=10;
  18.         System.out.println(grid[5][5]);
  19.  
  20.         for(int i=0; i<grid.length; i++){//row loop
  21.             for(int j=0; j<grid[i].length; j++){//col loop
  22.                 System.out.print(grid[i][j]+",");
  23.             }
  24.             System.out.println();
  25.         }
  26.  
  27.         int count=0;
  28.         for(int row=0; row<grid.length; row++){
  29.             for(int col=0; col<grid[row].length; col++){
  30.                 if(row%2==0){
  31.                     grid[row][col]=count;
  32.                 }
  33.                 else {
  34.                     int lastOne = grid[row].length - col - 1;
  35.                     grid[row][lastOne] = count;
  36.                 }
  37.                 count++;
  38.             }
  39.         }
  40.  
  41.         for(int[]row: grid){
  42.             for(int i: row){
  43.                 System.out.print(i+", ");
  44.             }
  45.             System.out.println();
  46.         }
  47.  
  48.  
  49.     }
  50. }
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement