LardaX

Equal-Pairs

Jul 12th, 2016
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Equal_Pairs
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int count = int.Parse(Console.ReadLine());
  14.             double value = 0.0;
  15.             double difference = 0.0;
  16.  
  17.             for (int i = 1; i <= count; i++)
  18.             {
  19.                 double firstNumber = double.Parse(Console.ReadLine());
  20.                 double secondNumber = double.Parse(Console.ReadLine());
  21.  
  22.                 if (value != 0)
  23.                 {
  24.                     difference = Math.Max(difference, Math.Abs(value - (firstNumber + secondNumber)));
  25.                 }
  26.  
  27.                 value = firstNumber + secondNumber;
  28.  
  29.             }
  30.  
  31.             if (difference == 0)
  32.             {
  33.                 Console.WriteLine("Yes, value=" + value);
  34.             }
  35.             else
  36.             {
  37.                 Console.WriteLine("No, maxdiff="+difference);
  38.             }
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment