Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- public class Main {
- public static void main(String[] args) {
- int[][] arr = {{1, 2, 3}, {1, 2, 3, 4}, {4, 5, 6, 7}};
- int[] arr2 = {1, 2, 3, 4, 5, 6, 7};
- System.out.println(subArray(arr, arr2));
- boolean array[][] = new boolean[5][10];
- boolRectangle(array);
- boolPrintArr(array);
- }
- public static int subArray(int[][] arr, int[] arr2) {
- int index = -1;
- int counter = 0;
- for (int i = 0; i < arr.length; i++) {
- for (int j = 0; j < arr[i].length; j++) {
- if (arr[i][j] == arr2[counter] && counter < arr2.length - 1) {
- counter++;
- index = i;
- }
- }
- counter = 0;
- }
- return index;
- }
- public static void printArr(boolean[] arr) {
- for (int i = 0; i < arr.length; i++) {
- if (i % 2 == 0)
- arr[i] = true;
- System.out.println(arr[i]);
- }
- }
- public static void boolRectangle(boolean[][] arr) {
- for (int col = 0; col < arr.length; col++) {
- for (int row = 0; row < arr[col].length; row++) {
- if (row == 0 || col == arr.length - 1 || col == 0 || row == arr[col].length - 1)
- arr[col][row] = true;
- }
- }
- }
- public static void boolPrintArr(boolean[][] arr) {
- for (int i = 0; i < arr.length; i++) {
- for (int j = 0; j < arr[i].length; j++) {
- System.out.print(arr[i][j] ? "*": " ");
- }
- System.out.println("");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement