Advertisement
Guest User

Untitled

a guest
Feb 12th, 2019
447
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.85 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _08MagicSum
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
  14.             int number = int.Parse(Console.ReadLine());
  15.  
  16.             for (int i = 0; i < array.Length - 1; i++)
  17.             {
  18.                 int currentNumber = array[i];
  19.              
  20.                 for (int j = i + 1; j < array.Length; j++)
  21.                 {
  22.  
  23.                     if (currentNumber + array[j] == number)
  24.                     {
  25.                         Console.WriteLine($"{currentNumber} {array[j]}");
  26.                        
  27.                     }                  
  28.                 }          
  29.             }
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement