Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static int curRow = 10;
- public static int curCol = 10;
- public static boolean stop = false;
- public static String[][] wordSearch = {{"H","M","G","R","R","A","U","S","G","U"},
- {"U","S","M","J","E","A","F","R","K","W"},
- {"X","M","C","L","P","J","D","N","M","S"},
- {"I","A","F","O","O","S","M","X","A","F"},
- {"R","R","J","O","L","O","O","P","T","N"},
- {"T","G","B","C","E","H","X","M","H","W"},
- {"A","O","G","H","V","Y","R","B","Y","M"},
- {"M","R","A","J","E","L","M","A","X","L"},
- {"R","P","W","A","D","T","A","C","Y","B"},
- {"H","N","S","A","I","T","E","R","Y","X"}};//Default
- private static void searchDiagonalRightToCenter(String word) {//Center to bottom Right. Diagnol Works, debug to go along column is needed
- int rowOn = 0;
- int colOn = 0;
- int resetableCol = curCol;
- resetableCol--;//Just resets everything then starts again.
- int decreaser = curCol;//What to decrease by everytime it runs 10,9,8,7 all the way to 1
- int resetableDec = decreaser;
- resetableDec--;
- char c;
- String toFind = word.toUpperCase();
- String developingInverse = "";
- int integer = 0;
- for(int row = 0; row < curRow; row++)//Matrices Row
- {
- for(int i = resetableCol; i <= resetableDec; i--)
- {
- String developingWord = "";
- integer = i;
- for(int j = integer; j <= resetableDec; j++,integer++)
- {
- System.out.println(j +" and " + i + " and " + resetableDec);
- c = wordSearch[integer][j].charAt(0);//Sets to whatever letter it is on
- char uC = Character.toUpperCase(c);
- developingWord = developingWord + "" +uC;
- System.out.println("On Row: " + row + " Started From: " + integer + " Now On: " + j);
- System.out.println("Processing Letter: " + wordSearch[j][integer] + " Adding Letter To: " + developingWord);
- if(toFind.equals(developingWord))
- {
- rowOn = row; colOn = i;
- rowOn++; colOn++;
- System.out.println("\nLocated Word: " + toFind + ". Word Was Diagonal Located Within The Row.");
- System.out.println("Row " + (rowOn) + " and Starting At Column " + (colOn));
- stop = true;
- return;
- }
- StringBuffer sb = new StringBuffer(developingWord);
- sb.reverse();
- developingInverse = sb.toString();
- if(toFind.equals(developingInverse)) {
- rowOn = row; colOn = i;
- rowOn++; colOn++;
- System.out.println("\nLocated Word: " + toFind + ". Word Was Diagonal Located Reversed Within The Row.");
- System.out.println("Row " + (rowOn) + " and Starting At Column " + (colOn));
- stop = true;
- return;
- }
- }
- }
- }
- System.out.println("\nNo Matching Word Was Found, Moving To Diagonal Center To Left.");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement