문자 배열 [4] [4]가 있습니다. 'a'와 나는 배열의 열을 다른 문자열과 비교하기위한 문자열로 저장하려고합니다. 하지만 문제는 문자열에 원래 요소를 계속 추가한다는 것입니다. 아래 코드는 배열에 "car"& "trip"이라는 단어를 포함하고 있으며이 단어를 다른 문자열과 비교하여 사실로 만듭니다.비교를 위해 char 배열 열을 문자열에 저장합니다.
char[][] puzzle = {{'a', 'c', 'h' ,'t'},
{'v', 'a', 'x', 'r'},
{'x', 'r', 'e', 'i'},
{'c', 'q', 'i', 'p'}
};
for(int row=0; row<puzzle.length; row++)
{
String match = "";
String matchword ="";
for(int col=0; col<puzzle.length; col++)
{
match += puzzle[col][row];
System.out.print(match);
}
System.out.println();
}
은 다음 문자열로 출력 될 때 : aavavxavxc ccacarcarq hhxhxehxei ttrtritrip
대신 :
어떤 도움을 여행 hxei carq avxc 여기 내 코드입니다 대단히 감사하겠습니다.