OpKaTa

Untitled

Jan 29th, 2020
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. package com.company;
  2.  
  3. import org.w3c.dom.ls.LSOutput;
  4.  
  5. import java.util.Scanner;
  6.  
  7. public class proBen {
  8. public static void main(String[] args) {
  9. Scanner scan = new Scanner(System.in);
  10. String[] firstArray = scan.nextLine().split(" ");
  11. String[] secondArray = scan.nextLine().split(" ");
  12.  
  13. int[] firstInt= new int[firstArray.length];
  14. int[] secondInt = new int [secondArray.length];
  15.  
  16. for (int i = 0; i <firstInt.length ; i++) {
  17. firstInt[i]=Integer.parseInt(firstArray[i]);
  18. }
  19.  
  20. for (int i = 0; i <secondInt.length ; i++) {
  21. secondInt[i] = Integer.parseInt(secondArray[i]);
  22. }
  23.  
  24. boolean notEqual = false;
  25. int sum =0;
  26. int secondSum=0;
  27. for (int i = 0; i <firstInt.length ; i++) {
  28. sum += firstInt[i];
  29. secondSum +=secondInt[i];
  30.  
  31. if (firstInt[i] != secondInt[i]){
  32. System.out.printf("Arrays are not identical. Found difference at %d index.",i);
  33. notEqual = true;
  34. break;
  35.  
  36.  
  37. }
  38. }
  39. if (sum == secondSum){
  40. System.out.printf("Arrays are identical. Sum: %d", sum);
  41. }
Advertisement
Add Comment
Please, Sign In to add comment