Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace PairsbyDifference
- {
- class MainClass
- {
- public static void Main(string[] args)
- {
- int[] arr = Console.ReadLine()
- .Split(' ')
- .Select(int.Parse)
- .ToArray();
- int diff = int.Parse(Console.ReadLine());
- int counter = 0;
- for (int i = 0; i < arr.Length ; i++)
- {
- for (int j = i; j < arr.Length; j++)
- {
- if ( arr[i] != arr[j] &&
- Math.Abs(arr[i] - arr[j]) == diff )
- {
- counter++;
- }
- }
- }
- Console.WriteLine(counter);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement