Created
June 6, 2015 12:28
-
-
Save vdonchev/3494fad90f44e3a1ea3a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
class OddEvenSum | |
{ | |
static void Main() | |
{ | |
int numbers = int.Parse(Console.ReadLine()); | |
int oddSum = 0; | |
int evenSum = 0; | |
for (int i = 1; i <= numbers * 2; i++) | |
{ | |
int currentDigit = int.Parse(Console.ReadLine()); | |
if (i % 2 == 0) | |
{ | |
evenSum += currentDigit; | |
} | |
else | |
{ | |
oddSum += currentDigit; | |
} | |
} | |
if (evenSum == oddSum) | |
{ | |
Console.WriteLine("Yes, sum={0}", oddSum); | |
} | |
else | |
{ | |
Console.WriteLine("No, diff={0}", Math.Abs(oddSum - evenSum)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment