Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Demo {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- int leftSum = 0;
- int righttSum = 0;
- for (int i = 0; i < n * 2; i++) {
- if (i < n) {
- leftSum += Integer.parseInt(scanner.nextLine());
- } else {
- righttSum += Integer.parseInt(scanner.nextLine());
- }
- }
- if (leftSum == righttSum) {
- System.out.println("Yes, sum = " + leftSum);
- } else {
- int difference = Math.abs(leftSum - righttSum);
- System.out.println("No, diff = " + difference);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement