package algorithms.matrixlayerrotation;

import java.util.Scanner;

public class Solution {

  private static final Scanner scanner = new Scanner(System.in);

  public static void main(String[] args) {
    String[] mnr = scanner.nextLine().split(" ");

    int m = Integer.parseInt(mnr[0]);
    int n = Integer.parseInt(mnr[1]);
    int r = Integer.parseInt(mnr[2]);

    int[][] matrix = new int[m][n];

    for (int i = 0; i < m; i++) {
      String[] matrixRowItems = scanner.nextLine().split(" ");
      scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");

      for (int j = 0; j < n; j++) {
        int matrixItem = Integer.parseInt(matrixRowItems[j]);
        matrix[i][j] = matrixItem;
      }
    }

    int[][] resultMatrix = rotateMatrix(matrix, r);
    printMatrix(resultMatrix);

    scanner.close();
  }

  private static void printMatrix(int[][] resultMatrix) {
    StringBuilder sb = new StringBuilder();

    for (int[] arrays : resultMatrix) {
      for (int array : arrays) {
        sb.append(array).append(" ");
      }
      sb.append(System.lineSeparator());
    }

    System.out.println(sb.toString());
  }

  static int[][] rotateMatrix(int[][] matrix, int rotations) {
    return matrix;
  }
}

@@ -749,16 +749,19 @@
 atrix, r
+, 0
 );%0A    p
@@ -1186,16 +1186,30 @@
 otations
+, int startRow
 ) %7B%0A    

add code to print the matrix