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