Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- using System.Text;
- using System.Threading.Tasks;
- namespace Exercice
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] values = Console.ReadLine().Split().Select(int.Parse).ToArray();
- int diff = int.Parse(Console.ReadLine());
- int counter = 0;
- bool pairs = false;
- for (int i = 0; i < values.Length; i++)
- {
- for (int j = i; j < values.Length; j++)
- {
- if (Math.Abs(values[i]-values[j]) == diff)
- {
- counter++;
- pairs = true;
- }
- }
- }
- if (!pairs)
- {
- Console.Write("0");
- }
- else
- {
- Console.Write(counter);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement