Advertisement
NelIfandieva

ExArrays_08_MagicSum

Jan 30th, 2020
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.69 KB | None | 0 0
  1. int[] array = Console.ReadLine()
  2.                 .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
  3.                 .Select(int.Parse)
  4.                 .ToArray();
  5.  
  6.             int magicNum = int.Parse(Console.ReadLine());
  7.  
  8.             for (int i = 0; i < array.Length - 1; i++)
  9.             {
  10.                 int current = array[i];
  11.  
  12.                 for (int j = i + 1; j < array.Length; j++)
  13.                 {
  14.                     int next = array[j];
  15.  
  16.                     if(current + next == magicNum)
  17.                     {
  18.                         Console.WriteLine("{0} {1}", current, next);
  19.                         break;
  20.                     }
  21.                 }
  22.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement