Advertisement
Guest User

Untitled

a guest
Oct 10th, 2017
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Numerics;
  6.  
  7. namespace TestGround
  8. {
  9. class Test
  10. {
  11. public static void Main()
  12. {
  13. int[] arr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  14. int difference = int.Parse(Console.ReadLine());
  15.  
  16. int pairs = 0;
  17. for (int i = 0; i < arr.Length-1; i++)
  18. {
  19. for (int j = i+1; j < arr.Length; j++)
  20. {
  21. if (Math.Abs(arr[i] - arr[j]) == difference)
  22. {
  23. pairs++;
  24. }
  25. }
  26. }
  27. Console.WriteLine(pairs);
  28. }
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement