void SetBoard()
{
int startCol = 0;
int endCol = N - 1;
int startRow = 0;
int endRow = N - 1;
int num = 1;
while (startRow <= endRow && startCol <= endCol)
{
for (int i = startCol; i <= endCol; i++)
{
board[startRow][i] = num;
num++;
}
for (int i = startRow + 1; i <= endRow; i++)
{
board[i][endCol] = num;
num++;
}
for (int i = endCol - 1; i >= startCol; i--)
{
board[endRow][i] = num;
num++;
}
for (int i = endRow - 1; i > startCol; i--)
{
board[i][startCol] = num;
num++;
}
startCol++;
endCol--;
startRow++;
endRow--;
}
}
다른 풀이
znffjdznffjd
작성일
21.08.19 16:10
조회수
155
댓글 0