我是一个初学者,我想知道是否有人可以告诉我这个词搜索我做错了什么?我坚持检查形式参数中指定的单词的每一行,目前它不做任何类型的检查,它的 jst 是一个基本的布尔方法,如果在数组的一行中找到一个单词,则返回 true。假设单词搜索数组是长方形的
public boolean checkRow( char[][] puzzle, String w)
{
int counter = 0;
boolean match = true;
for ( int row = 0; row < puzzle.length; row++)
{
counter = 0;
for ( int col = 0; col < puzzle[row].length; col++)
{
if ( counter <= w.length() )
{
char word = puzzle[row][col];
if( w.charAt(counter) == word)
{
match = true;
counter++;
}
}
else if ((counter == w.length()) && (match == true))
{
return true;
}
else
{
match = false;
counter = 0;
}
}
}
return match;
}