TheBulgarianWolf

Magic SUM

Oct 16th, 2020 (edited)
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.89 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics.CodeAnalysis;
  4. using System.Linq;
  5. using System.Numerics;
  6.  
  7. namespace SoftuniExercisesWithVariables
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.             Console.WriteLine("Enter your array here: ");
  15.             int[] array = Console.ReadLine().Split(" ").Select(int.Parse).ToArray();
  16.             Console.WriteLine("Enter your number here: ");
  17.             int number = int.Parse(Console.ReadLine());
  18.             for (int i = 0; i < array.Length-1; i++)
  19.             {
  20.                 for(int k = i+1; k < array.Length; k++)
  21.                 {
  22.                     if((array[i] + array[k]) == number)
  23.                     {
  24.                         Console.WriteLine(array[i] + " " + array[k]);
  25.                     }
  26.                 }
  27.                
  28.             }
  29.  
  30.         }
  31.     }
  32. }
  33.  
Add Comment
Please, Sign In to add comment