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