Skip to content

Instantly share code, notes, and snippets.

@vdonchev
Created June 6, 2015 12:28
Show Gist options
  • Save vdonchev/3494fad90f44e3a1ea3a to your computer and use it in GitHub Desktop.
Save vdonchev/3494fad90f44e3a1ea3a to your computer and use it in GitHub Desktop.
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