Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _12.Equal_Pairs
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- int oldSum = 0;
- int currentSum = 0;
- int maxDiff = 0;
- int currentDiff = 0;
- for (int i = 0; i < n; i++)
- {
- int n1 = int.Parse(Console.ReadLine());
- int n2 = int.Parse(Console.ReadLine());
- currentSum = n1 + n2;
- if (i > 0)
- {
- currentDiff = Math.Abs(oldSum - currentSum);
- if (currentDiff > maxDiff)
- {
- maxDiff = currentDiff;
- }
- }
- oldSum = currentSum; //Това е важно да е в края на цикъла
- }
- if (currentDiff == 0) //Тук се замотах - вместо да правя проверка за разликата, аз правих проверки на сумите
- {
- Console.WriteLine("Yes, value={0}", oldSum);
- }
- else
- {
- Console.WriteLine("No, maxdiff={0}", maxDiff);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment