Created
February 29, 2016 17:41
-
-
Save Kiso-blg/159d10032a26ab5c963c to your computer and use it in GitHub Desktop.
18_Equal_Pairs
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; | |
namespace _18_Equal_Pairs | |
{ | |
class EqualPairs | |
{ | |
static void Main(string[] args) | |
{ | |
int length = int.Parse(Console.ReadLine());; | |
int sum = 0; | |
int maxDifference = int.MinValue; | |
bool allEqual = true; | |
for (int i = 0; i < length; i++) | |
{ | |
int number1 = int.Parse(Console.ReadLine()); | |
int number2 = int.Parse(Console.ReadLine()); | |
int newSum = number1 + number2; | |
if (i == 0) | |
{ | |
sum = number1 + number2; | |
} | |
if (newSum != sum) | |
{ | |
allEqual = false; | |
int difference = Math.Abs(newSum - sum); | |
maxDifference = Math.Max(maxDifference, difference); | |
sum = newSum; | |
} | |
} | |
if (allEqual) | |
{ | |
Console.WriteLine("Yes, value={0}", sum); | |
} | |
else | |
{ | |
Console.WriteLine("No, maxdiff={0}", maxDifference); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment