Skip to content
Advertisement

Tag: multidimensional-array

Printing a snake pattern using an array

I’m having trouble with an assignment where we are required to print out this array: My code is somewhat correct but it is not printing 10 and 19 where it should be. My output: My code: Can anyone detect what is causing the error? Any help would be appreciated. Answer This will generate the “snaking” pattern you described. It could

Java – How to Solve this 2D Array Hour Glass?

I am working on a problem where I’ve to print the largest sum among all the hourglasses in the array. You can find the details about the problem here- What I tried: Input: Output: Expected Output: Screenshot: I don’t know where I’m doing wrong. I cannot understand why the expected output is 13. According to the description given in the

Why can’t i generate this 10×10 2D array?

I am trying to generate this 2D Array maze 10 by 10 with numbers 0-9 in each row for 10 rows, but I keep getting array out of bounds exception. I double checked my indexes and the loop format and everything looks standard. What is going on here? Why am I getting the out of bounds exception? Answer When you

Java array manipulation, invert an int[][] array

I am trying to flip each col in this array to invert the image. However, when I run my code, I get a mirror image of the second half of the image, for some ridiculous reason, that I cannot figure out. Can someone please tell me why this only works half-way? someArray is an int[][] array defined elsewhere in my

Advertisement