Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) throws IOException {
- BufferedReader rd = new BufferedReader(new InputStreamReader(System.in));
- int[] info = Arrays.stream(rd.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
- int row = info[0];
- int cols = info[1];
- int[][] mat = new int[row][cols];
- for (int i = 0; i < row; i++)
- mat[i] = Arrays.stream(rd.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
- int col = cols - 1;
- row--;
- while (row >= 0) {
- int r = row;
- int c = col;
- while (c < cols && r >= 0)
- System.out.print(mat[r--][c++] + " ");
- System.out.println();
- if (--col == -1) {
- col = 0;
- row--;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment