privatevoidprintEdge(int[][] matrix, int leftRow, int leftColumn, int rightRow, int rightColumn){ if (leftRow == rightRow) { for (int i = leftColumn; i <= rightColumn; i++) { result[index++] = matrix[leftRow][i]; } } elseif (leftColumn == rightColumn) { for (int i = leftRow; i <= rightRow; i++) { result[index++] = matrix[i][leftColumn]; } } else { int curColumn = leftColumn; int curRow = leftRow;
while (curColumn != rightColumn) { result[index++] = matrix[leftRow][curColumn++]; }
while (curRow != rightRow) { result[index++] = matrix[curRow++][rightColumn]; }
while (curColumn != leftColumn) { result[index++] = matrix[rightRow][curColumn--]; }