Advertisement
koksibg

Pairs_by_Difference

Feb 3rd, 2017
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.69 KB | None | 0 0
  1. using System;
  2.  
  3. using System.Linq;
  4.  
  5. namespace Pairs_by_Difference
  6. {
  7.     class Pairs_by_Difference
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
  12.             int difference = int.Parse(Console.ReadLine());
  13.             int count = 0;
  14.             for (int i = 0; i < array.Length; i++)
  15.             {
  16.                 for (int j = 1; j < array.Length; j++)
  17.                 {
  18.                     if (array[j] - array[i] == difference)
  19.                     {
  20.                         count++;
  21.                     }
  22.                 }
  23.             }
  24.             Console.WriteLine(count);
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement