fork download
  1. import java.io.*;
  2. import java.util.*;
  3.  
  4. public class Main {
  5. public static void main(String[] args) {
  6. Scanner in = new Scanner(System.in);
  7. PrintWriter out = new PrintWriter(System.out);
  8.  
  9. int n = in.nextInt();
  10. int [][] x = new int [n][n];
  11. for (int i = 0; i < n; i++)
  12. for (int j = 0; j < n; j++)
  13. x[i][j] = in.nextInt();
  14. int r = in.nextInt();
  15. int c = in.nextInt();
  16. for (int i = 0; i < r; i++) {
  17. for (int j = 0; j < c; j++)
  18. out.print(x[i][j] + " ");
  19. out.print("\n");
  20. }
  21.  
  22. out.flush();
  23. }
  24. }
Success #stdin #stdout 0.07s 2184192KB
stdin
4
1 2 3 4
5 6 7 8
9 1 2 3
4 5 6 7
3 2
stdout
1 2 
5 6 
9 1