LusienGG

[C#][Arrays] Tripple Sum

May 10th, 2016
150
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 Practice
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int[] nums = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  14.             bool notEql = true;
  15.             for (int i = 0; i < nums.Length; i++)
  16.             {
  17.                 for (int j = i+1; j < nums.Length; j++)
  18.                 {
  19.                     if (nums.Contains(nums[i] + nums[j]))
  20.                     {
  21.                         Console.WriteLine($"{nums[i]} + {nums[j]} == {nums[i] + nums[j]}");
  22.                         notEql = false;
  23.  
  24.                     }
  25.                 }
  26.             }
  27.             if (notEql)
  28.             {
  29.                 Console.WriteLine("No");
  30.             }
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment