Advertisement
Stan0033

Untitled

Jun 21st, 2021
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace _06.EqualSum
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. int[] arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
  11. int[] arr2 = arr;
  12. int GivenNumber = GetInt();
  13.  
  14.  
  15. int[] Pairs1 = new int[arr.Length];
  16. int[] Pairs2 = new int[arr.Length];
  17. int PairsCounter = 0;
  18. for (int i = 0; i < arr.Length; i++)
  19. {
  20. for (int x = 0; x < arr2.Length; x++)
  21. {
  22. if (x!=i)
  23. {
  24. if (arr[i] + arr[x] == GivenNumber)
  25. {
  26.  
  27. if (!(Pairs1.Contains(arr[i]) && Pairs2.Contains(arr[x])))
  28. {
  29. Pairs1[i] = arr[i];
  30. Pairs2[i] = arr[x];
  31.  
  32. PairsCounter++;
  33. }
  34.  
  35. }
  36. }
  37.  
  38. }
  39. }
  40. //-----------------------------------------------------------------------
  41. //-----------------------------------------------------------------------
  42. // PRINT
  43. //-----------------------------------------------------------------------
  44. for (int i = 0; i <= PairsCounter; i++)
  45. {
  46.  
  47. Console.WriteLine($"{Pairs1[i]} {Pairs2[i]}");
  48.  
  49.  
  50.  
  51.  
  52. }
  53. //-----------------------------------------------------------------------
  54. //-----------------------------------------------------------------------
  55.  
  56. }
  57. static int GetInt() { return int.Parse(Console.ReadLine()); }
  58. }
  59. }
  60.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement