YavorJS

Pairs_by_Difference

Jul 30th, 2016
368
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _10.Pairs_by_Difference
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int[] numbers = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  14. int n = int.Parse(Console.ReadLine());
  15. int counter = 0;
  16.  
  17. for (int i = 0; i < numbers.Length; i++)
  18. {
  19. for (int k = 0; k < numbers.Length; k++)
  20. {
  21. if (Math.Abs(numbers[k]-numbers[i])==n && i<k)
  22. {
  23. //Console.WriteLine(numbers[i] + " " + numbers[k]);
  24. counter++;
  25. }
  26. }
  27. }//end of for
  28.  
  29. Console.WriteLine(counter);
  30.  
  31. }
  32. }
  33. }
RAW Paste Data