Run Code  | API  | Code Wall  | Users  | Misc  | Feedback  | Login  | Theme  | Privacy  | Patreon 

Path finding given 2D array


            
                
            
 run  | edit  | history  | help 0

Can you please show the solution if the start is everywhere on a first line, where "1" is; the finish point is also anywhere, where "1" on a bottom line is. the binary matrix size itself can be customized by user input. The search can go only right, left and down. Here is my code for the matrix: `public static void main(String[] args) {

    Scanner in = new Scanner(System.in);
    System.out.print("Enter size of the cheese: ");

    int matrix_size = in.nextInt();
    Random r = new Random();
    int[][] cheese = new int[matrix_size][matrix_size];
    for (int i = 0; i < matrix_size; i++) {
        for (int j = 0; j < matrix_size; j++) {
           cheese [i][j] = r.nextInt(2);
            System.out.print(cheese[i][j] + "\t");
        }
        System.out.print("\n");

    }`
  by  Nele, 1 years ago




Please log in to post a comment.
1a
3