Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> numbers = Console.ReadLine().Split().Select(int.Parse).ToList();
- int diff = int.Parse(Console.ReadLine());
- int k = 0;
- for (int i = 0; i < numbers.Count - 1; i++)
- {
- for (int n = i + 1; n < numbers.Count; n++)
- {
- if (Math.Abs(numbers[i] - numbers[n]) == diff)
- {
- k += 1;
- }
- }
- }
- Console.WriteLine(k);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement