Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _02.Pairs
- {
- class Program
- {
- static void Main()
- {
- string[] input = Console.ReadLine().Split(' ');
- int maxDiff = 0;
- int oldPair = 0;
- int valueOne = 0;
- int valueTwo = 0;
- int currentPair = 0;
- for (int i = 0, k = 0; i < input.Length / 2; i++, k += 2)
- {
- valueOne = int.Parse(input[k]);
- valueTwo = int.Parse(input[k + 1]);
- oldPair = currentPair;
- currentPair = valueOne + valueTwo;
- if (i != 0 && currentPair != oldPair)
- {
- int diff = Math.Abs(currentPair - oldPair);
- if (diff > maxDiff)
- {
- maxDiff = diff;
- }
- }
- else
- {
- oldPair = currentPair;
- }
- }
- if (maxDiff != 0)
- {
- Console.WriteLine("No, maxdiff=" + maxDiff);
- }
- else
- {
- Console.WriteLine("Yes, value=" + (valueOne + valueTwo));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement