Advertisement
Mishakis

EvenOddSum

Aug 2nd, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.80 KB | None | 0 0
  1. package com.company;
  2.  
  3. import com.sun.org.apache.xpath.internal.SourceTree;
  4.  
  5. import java.time.chrono.MinguoEra;
  6. import java.util.Scanner;
  7.  
  8. public class Main {
  9.  
  10.     public static void main(String[] args) {
  11.         Scanner scanner = new Scanner(System.in);
  12.  
  13.         int n = Integer.parseInt(scanner.nextLine());
  14.         int sumL=0;
  15.         int sumR=0;
  16.  
  17.         for (int i = 0; i < n ; i++) {
  18.             if(i % 2 == 0){
  19.                 sumL += Integer.parseInt(scanner.nextLine());
  20.             }else{
  21.                 sumR += Integer.parseInt(scanner.nextLine());
  22.             }
  23.  
  24.         }
  25.  
  26.  
  27.  
  28.         int diff = Math.abs(sumL-sumR);
  29.  
  30.         if(diff!=0){
  31.             System.out.println("No, diff " + diff);
  32.         }else{
  33.             System.out.println("Yes, sum " + sumL);
  34.         }
  35.  
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement