Advertisement
Guest User

Untitled

a guest
May 28th, 2016
130
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.Threading.Tasks;
  6.  
  7. namespace Pairs
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
  14. int diff = int.Parse(Console.ReadLine());
  15.  
  16. int pairs = 0;
  17. for (int i = 0; i < input.Length; i++)
  18. {
  19. for (int j = i + 1; j < input.Length; j++)
  20. {
  21. if (Math.Abs(input[i] - input[j]) == diff)
  22. {
  23. pairs++;
  24. }
  25. }
  26. }
  27. Console.WriteLine(pairs);
  28. }
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement