Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Equal_Pairs
- {
- class Program
- {
- static void Main(string[] args)
- {
- int countNum = int.Parse(Console.ReadLine());
- double beforePearSum = 0;
- double maxDiff = 0;
- double pear = 0;
- int i = 0;
- double num1 = 0;
- double num2 = 0;
- for (; i < countNum; i++)
- {
- if (i == 0)
- {
- num1 = double.Parse(Console.ReadLine());
- num2 = double.Parse(Console.ReadLine());
- beforePearSum = num1 + num2;
- }
- else
- {
- num1 = double.Parse(Console.ReadLine());
- num2 = double.Parse(Console.ReadLine());
- pear = num1 + num2;
- double Diff = Math.Abs(pear - beforePearSum);
- if (Diff > maxDiff)
- {
- maxDiff = Diff;
- }
- beforePearSum = pear;
- }
- }
- if (i == 1 && num1 == num2)
- {
- Console.WriteLine($"Yes, value={beforePearSum}");
- }
- else if (maxDiff == 0)
- {
- Console.WriteLine($"Yes, value={pear}");
- }
- else
- {
- Console.WriteLine($"No, maxdiff={maxDiff}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement