Advertisement
vov44k

Untitled

Feb 28th, 2022
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.12 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.Scanner;
  3.  
  4.  
  5. public class Main {
  6.  
  7.     public static void main(String[] args) throws IOException {
  8.         Scanner in = new Scanner(System.in);
  9.         if (args.length > 0 && args[0].equals("LOCAL")) {
  10.             in = new Scanner(new File("data/in.txt"));
  11.             System.setOut(new PrintStream(new FileOutputStream("data/out.txt")));
  12.         }
  13.         PrintWriter out = new PrintWriter(new File("output.txt"));
  14.  
  15.         int N = in.nextInt();
  16.         int M = in.nextInt();
  17.  
  18.         int[][] matrix = new int[N][M];
  19.  
  20.         for (int i = 0; i < N; i++)
  21.             for (int j = 0; j < M; j++) {
  22.                 matrix[i][j] = in.nextInt();
  23.             }
  24.  
  25.         int[][] arr = new int[M][N];
  26.         for (int i = 0; i < N; i++)
  27.             for (int j = 0; j < M; j++) {
  28.                 arr[j][i] = matrix[N - 1 - i][j];
  29.             }
  30.  
  31.         out.println(M + " " + N);
  32.         for (int i = 0; i < M; i++) {
  33.             for (int j = 0; j < N; j++) {
  34.                 out.print(arr[i][j] + " ");
  35.             }
  36.             out.println();
  37.         }
  38.         in.close();
  39.     }
  40. }
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement