Advertisement
Ronka

Untitled

Jun 8th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace Exercice
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. int[] values = Console.ReadLine().Split().Select(int.Parse).ToArray();
  15.  
  16. int diff = int.Parse(Console.ReadLine());
  17.  
  18. int counter = 0;
  19. bool pairs = false;
  20.  
  21. for (int i = 0; i < values.Length; i++)
  22. {
  23. for (int j = i; j < values.Length; j++)
  24. {
  25. if (Math.Abs(values[i]-values[j]) == diff)
  26. {
  27. counter++;
  28. pairs = true;
  29. }
  30. }
  31. }
  32.  
  33. if (!pairs)
  34. {
  35. Console.Write("0");
  36. }
  37. else
  38. {
  39. Console.Write(counter);
  40. }
  41.  
  42.  
  43. }
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement