Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.72 KB | None | 0 0
  1. using System;
  2. class Program
  3. {
  4.     static void Main()
  5.     {
  6.         int n = int.Parse(Console.ReadLine());
  7.         int evenSum = 0;
  8.         int oddSum = 0;
  9.  
  10.         for (int i = 0; i < n; i++)
  11.         {
  12.             int inputNumber = int.Parse(Console.ReadLine());
  13.             if (i % 2 == 0)
  14.             {
  15.                 evenSum += inputNumber;
  16.             }
  17.             else
  18.             {
  19.                 oddSum += inputNumber;
  20.             }
  21.         }
  22.  
  23.         if (evenSum == oddSum)
  24.         {
  25.             Console.WriteLine("Yes sum= {0}", evenSum);
  26.         }
  27.         else
  28.         {
  29.             int diff = Math.Abs(evenSum - oddSum);
  30.             Console.WriteLine("No diff= {0}", diff);
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement