Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Dance {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8. int n = Integer.parseInt(scanner.nextLine());
  9.  
  10. int leftSum = 0;
  11. int rightSum = 0;
  12.  
  13. for (int i = 1; i <= n ; i++) {
  14. int number = Integer.parseInt(scanner.nextLine());
  15. leftSum += number;
  16. }
  17. for (int i = 1; i <= n ; i++) {
  18. int number = Integer.parseInt(scanner.nextLine());
  19. rightSum += number;
  20. }
  21. int diff = Math.abs(leftSum - rightSum);
  22. if (leftSum == rightSum) {
  23. System.out.println("Yes, sum = " + leftSum);
  24. } else {
  25. System.out.println("No, diff = " + diff);
  26. }
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement