Advertisement
nov0

Z10_StrictlyIdentical

May 30th, 2015
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.93 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Z10_StrictlyIdentical {
  4.     public static void main(String[] args) {
  5.  
  6.         Scanner input = new Scanner(System.in);
  7.         System.out.println("Enter a length of an array: ");
  8.         int n = input.nextInt();
  9.  
  10.         int[] arr1 = createArr(n);
  11.         System.out.println("Enter second arr: \n\n");
  12.         int[] arr2 = createArr(n);
  13.  
  14.         System.out.println("Two lists are" + (isIdentic(arr1, arr2) ? "" : " not") + " strictly indentical.");
  15.         input.close();
  16.     }
  17.  
  18.     public static boolean isIdentic(int[] arr1, int[] arr2) {
  19.         for (int i = 0; i < arr1.length; i++) {
  20.             if (arr1[i] != arr2[i]) {
  21.                 return false;
  22.             }
  23.         }
  24.         return true;
  25.     }
  26.  
  27.     public static int[] createArr(int n) {
  28.         Scanner input = new Scanner(System.in);
  29.         int[] arr = new int[n];
  30.         for (int i = 0; i < n; i++) {
  31.             System.out.println("Enter value at arr[" + i + "] ");
  32.             arr[i] = input.nextInt();
  33.         }
  34.         System.out.println("\n\n");
  35.  
  36.         return arr;
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement