Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace ConsoleApp1
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10.  
  11. {
  12. List<int> numbers = Console.ReadLine().Split().Select(int.Parse).ToList();
  13. int diff = int.Parse(Console.ReadLine());
  14. int k = 0;
  15.  
  16. for (int i = 0; i < numbers.Count - 1; i++)
  17. {
  18. for (int n = i + 1; n < numbers.Count; n++)
  19. {
  20. if (Math.Abs(numbers[i] - numbers[n]) == diff)
  21. {
  22. k += 1;
  23. }
  24. }
  25. }
  26.  
  27. Console.WriteLine(k);
  28. }
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement