Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.11 KB | None | 0 0
  1. public static void task19() {
  2.         Scanner scan = new Scanner(System.in);
  3.         int n = Integer.parseInt(scan.nextLine());
  4.         int[][] matrix = new int[n][n];
  5.         for (int i = 0; i < n; i++) {
  6.             for (int j = 0; j < n; j++) {
  7.                 matrix[i][j] = scan.nextInt();
  8.             }
  9.         }
  10.         boolean flag = false;
  11.         ArrayList numberOfRows = new ArrayList();
  12.         ArrayList numberOfColumns = new ArrayList();
  13.         for (int i = 0; i < n; i++) {
  14.             for (int j = 0; j < n; j++) {
  15.                 if (matrix[i][j] != 0) {
  16.                     flag = false;
  17.                     continue;
  18.                 } else flag = true;
  19.             }
  20.             if (flag == true)
  21.                 numberOfRows.add(i);
  22.         }
  23.         flag = false;
  24.         for (int i = 0; i < n; i++) {
  25.             for (int j = 0; j < n; j++) {
  26.                 if (matrix[j][i] != 0) {
  27.                     flag = false;
  28.                     continue;
  29.                 } else flag = true;
  30.             }
  31.             if (flag == true)
  32.                 numberOfColumns.add(i);
  33.         }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement