Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Pairs_By_Difference
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] arr = Console.ReadLine()
- .Split(' ')
- .Select(int.Parse)
- .ToArray();
- int difference = int.Parse(Console.ReadLine());
- int count = 0;
- for (int i = 0; i < arr.Length; i++)
- {
- for (int j = i + 1; j < arr.Length; j++)
- {
- if (arr[i] - arr[j]) == difference || arr[j] - arr[i]) == difference)
- {
- count++;
- }
- }
- }
- Console.WriteLine(count);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement