java - How would I modify my code to search a multidimensional array diagonally from left to right and right to left? -


I have a multi-dimensional array to search from left to right and left to right.

Do I need to search the array from right to the bottom right, from the bottom left to the right, the bottom has been left at the top right, and the bottom right Side.

What would I need to change in my existing ways to create a new method for doing what?

  // Find the public static string from left to right Lettroit (four [] [] board, string word) {four [] letters = words. Charaire (); (Int i = 0; i & lt; board.length; i ++) {for (int j = 0; j & lt; board [i]. Length; j ++) {boolean found = true; (Int k = 0; k & lt; letters.length; k ++) {if ((j + k> = board [i]. Length) || (letter [k]! = Board [i ] [J + k])) {found = false; break; }} If (found) {return "string" + word + "row =" + + "col =" + j; }}} Return "string" + word + "did not get"; } // end findLeftToRight // Right to Left Public Static String for Rudder to Left (four [] [] Board, String Word) {char [] letters = word.toCharArray (); (Int i = board, lang -1; i> i-) {for (int j = board [i] length-1; j & gt; -1; j--) {boolean Found = true; (Int k = 0; k & lt; letters.length; k ++) {if ((j - k & lt; 0) || (letter [k]! = Board [i] [jk])) {Found = false; break; }} If (found) {return "string" + word + "row =" + + "col =" + j; }}} Return "string" + word + "did not get"; } // end findLeftToRight    

So I think your multi-dimensional array means a cube The row and column have the same length.

From right to left bot to right board [i] [i];

Compare the top right side of the boat, but compare it with the board [length-i] [i]

The board for the left bot on top [i ] To compare with [length-i]

the bot on the top will be compared with the left board [length-i] [length-i]

to loop them all From to

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -