Advertisement
Guest User

Untitled

a guest
May 24th, 2016
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.71 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _10.Pairs
  6. {
  7.     class Pairs
  8.     {
  9.         static void Main()
  10.         {
  11.             var input = Console.ReadLine().Split().Select(long.Parse).ToList();
  12.             long neededNumber = long.Parse(Console.ReadLine());
  13.             int counter = 0;
  14.             for (int i = 0; i < input.Count; i++)
  15.             {
  16.                 for (int j = i + 1; j < input.Count; j++)
  17.                 {
  18.                     if (Math.Abs(input[i] - input[j]) == neededNumber)
  19.                     {
  20.                         counter++;
  21.                     }
  22.                 }
  23.             }
  24.             Console.WriteLine(counter);
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement