Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) throws IOException {
- Scanner in = new Scanner(System.in);
- if (args.length > 0 && args[0].equals("LOCAL")) {
- in = new Scanner(new File("data/in.txt"));
- System.setOut(new PrintStream(new FileOutputStream("data/out.txt")));
- }
- PrintWriter out = new PrintWriter(new File("output.txt"));
- int N = in.nextInt();
- int M = in.nextInt();
- int[][] matrix = new int[N][M];
- for (int i = 0; i < N; i++)
- for (int j = 0; j < M; j++) {
- matrix[i][j] = in.nextInt();
- }
- int[][] arr = new int[M][N];
- for (int i = 0; i < N; i++)
- for (int j = 0; j < M; j++) {
- arr[j][i] = matrix[N - 1 - i][j];
- }
- out.println(M + " " + N);
- for (int i = 0; i < M; i++) {
- for (int j = 0; j < N; j++) {
- out.print(arr[i][j] + " ");
- }
- out.println();
- }
- in.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement