Advertisement
DanikYakush

Task37

Jul 7th, 2022
838
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 KB | None | 0 0
  1.  public static void task37() {
  2.         int[][] a = new int[10][20];
  3.         Random random = new Random();
  4.         for (int i = 0; i < 10; ++i) {
  5.             for (int j = 0; j < 20; ++j) {
  6.                 a[i][j] = random.nextInt(16);
  7.             }
  8.         }
  9.         for (int i = 0; i < 10; ++i) {
  10.             for (int j = 0; j < 20; ++j) {
  11.                 System.out.print(a[i][j] + " ");
  12.             }
  13.             System.out.println();
  14.         }
  15.         System.out.println();
  16.         System.out.print("Indexes of rows where number 5 constists 3 or more times: ");
  17.         for (int i = 0; i < 10; i++) {
  18.             int counter = 0;
  19.             for (int j = 0; j < 20; ++j) {
  20.                 if (a[i][j] == 5) {
  21.                     counter++;
  22.                 }
  23.             }
  24.             if (counter >= 3) {
  25.                 System.out.print(i + " ");
  26.             }
  27.         }
  28.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement