Advertisement
ibakyrdjiev

Pairs

Jul 12th, 2014
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.12 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. class Program
  8. {
  9.     static void Main(string[] args)
  10.     {
  11.         string a = Console.ReadLine();
  12.         string[] spaces = a.Split(' ');
  13.         int[] array = new int[spaces.Length];
  14.         int b = 0;
  15.  
  16.         for (int i = 0; i < spaces.Length; i++)
  17.         { //0 1 2 3 4 5 6 7
  18.             //          0 1 ; 2 3; 4 5; 67
  19.  
  20.             array[i] = int.Parse(spaces[i]);
  21.         }
  22.         int[] results = new int[spaces.Length / 2];
  23.         for (int i = 0; i < spaces.Length / 2; i++)
  24.         {
  25.             results[i] = array[i + b] + array[i + b + 1];
  26.             b++;
  27.         }
  28.         for (int i = 0; i < spaces.Length / 2; i++)
  29.         {
  30.             if (results[i] == results.Average())
  31.             {
  32.                 Console.WriteLine("Yes, value={0}", results[i]);
  33.                 break;
  34.             }
  35.             else
  36.             {
  37.  
  38.                 Console.WriteLine("No, maxdiff={0}", Math.Abs(results.Min() - results.Max()));
  39.                 break;
  40.             }
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement