Advertisement
pavlinpetkov88

OddEvenSum

Nov 14th, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.13 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication17
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var input = int.Parse(Console.ReadLine());
  14.  
  15.             int sumDigitEven = 0;
  16.             int sumDigitOdd = 0;
  17.  
  18.             for (int count = 1; count <= input; count++)
  19.             {
  20.                 var digit = int.Parse(Console.ReadLine());
  21.                
  22.                 {
  23.                     if (count % 2 == 0)
  24.                     {
  25.                         sumDigitEven += digit;
  26.                     }
  27.                     else
  28.                     {
  29.                         sumDigitOdd += digit;
  30.                     }
  31.                    
  32.                 }
  33.             }
  34.  
  35.             if (sumDigitEven == sumDigitOdd)
  36.             {
  37.                 Console.WriteLine("Yes Sum = {0}", sumDigitEven);
  38.             }
  39.             else
  40.             {
  41.                 Console.WriteLine("No Diff = {0}", Math.Abs(sumDigitEven - sumDigitOdd));
  42.             }
  43.            
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement