Aliendreamer

even sums softuni

Jun 9th, 2018
598
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.14 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 issue12
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.             var number = double.Parse(Console.ReadLine());
  15.  
  16.  
  17.             double sum = 0;
  18.             double sum2 = 0;
  19.             double max = 0;
  20.             double avg = 0;
  21.  
  22.  
  23.  
  24.  
  25.             for (int i = 1; i <= number; i++)
  26.             {
  27.                 sum2 = sum;
  28.                 var a = double.Parse(Console.ReadLine());
  29.                 var b = double.Parse(Console.ReadLine());
  30.  
  31.                 sum = a + b;
  32.  
  33.                 if (i == 1)
  34.                 {
  35.                     continue;
  36.                 }
  37.                 avg = Math.Abs(sum - sum2);
  38.  
  39.                 if (avg > max)
  40.                 {
  41.                     max = avg;
  42.                 }
  43.  
  44.             }
  45.             if (max == 0)
  46.             {
  47.                 Console.WriteLine("Yes, value={0}", sum);
  48.             }
  49.             else
  50.             {
  51.  
  52.                 Console.WriteLine("No, maxdiff={0}", max);
  53.             }
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment