Search
Duplicate

๋ถ„ํ• ์ •๋ณต

โ€ข
๋ณดํ†ต ์žฌ๊ท€๋ฅผ ์ด์šฉ
โ€ข
์˜ค๋ฒ„ํ—ค๋“œ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค๋ฉด ์Šคํƒ, ํ ์ด์šฉ

๋ฐฉ๋ฒ•

1.
row, col, size ๋กœ ์žฌ๊ท€
void partition(int row, int col, int size) { if (check()) { return; // ์กฐ๊ฑด์— ๋งŒ์กฑํ•˜๋ฉด ์žฌ๊ท€ ์ข…๋ฃŒ } size = size / 2; partition(row, col, size); partition(row, col + size, size); partition(row + size, col, size); partition(row + size, col + size, size); }
Java
๋ณต์‚ฌ
2.
์ƒˆ๋กœ ๋งŒ๋“  array, size ๋กœ ์žฌ๊ท€
void partition(int[][] array, int size) { if (check()) { return; // ์กฐ๊ฑด์— ๋งŒ์กฑํ•˜๋ฉด ์žฌ๊ท€ ์ข…๋ฃŒ } size = size / 2; for (int rowCnt = 0; rowCnt < 2; rowCnt++) { for (int colCnt = 0; colCnt < 2; colCnt++) { int newRow = 0; int[][] newArray = new int[newNum][newNum]; for (int row = (cnt * newNum); row < ((cnt + 1) * newNum); row++) { int newCol = 0; for (int col = (colCnt * newNum); col < ((colCnt + 1) * newNum); col++) { newArray[newRow][newCol] = array[row][col]; newCol += 1; } newRow += 1; } separation(newArray, newNum); } } }
Java
๋ณต์‚ฌ
์ „์ฒด์ ์œผ๋กœ ๋กœ์ง์€ ๊ฐ™์€๋ฐ, ๋ฐฉ๋ฒ• 1์ด ํ›จ์”ฌ ๊ตฌ์ƒํ•˜๊ธฐ ํŽธํ•จ!