Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void task37() {
- int[][] a = new int[10][20];
- Random random = new Random();
- for (int i = 0; i < 10; ++i) {
- for (int j = 0; j < 20; ++j) {
- a[i][j] = random.nextInt(16);
- }
- }
- for (int i = 0; i < 10; ++i) {
- for (int j = 0; j < 20; ++j) {
- System.out.print(a[i][j] + " ");
- }
- System.out.println();
- }
- System.out.println();
- System.out.print("Indexes of rows where number 5 constists 3 or more times: ");
- for (int i = 0; i < 10; i++) {
- int counter = 0;
- for (int j = 0; j < 20; ++j) {
- if (a[i][j] == 5) {
- counter++;
- }
- }
- if (counter >= 3) {
- System.out.print(i + " ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement