Advertisement
miroLLL

TripleSum-100Points

Feb 5th, 2018
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.07 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace _04Problem_TripleSum
  5. {
  6.     class TripleSum
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             long[] numbers = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
  11.             bool haveMatch = false;
  12.  
  13.             for (int leftDigit = 0; leftDigit < numbers.Length; leftDigit++)
  14.             {
  15.                 for (int rightDigit = leftDigit + 1; rightDigit < numbers.Length; rightDigit++)
  16.                 {
  17.                     for (int sum = 0; sum < numbers.Length; sum++)
  18.                     {
  19.                         if (numbers[leftDigit] + numbers[rightDigit] == numbers[sum])
  20.                         {
  21.                             haveMatch = true;
  22.                             Console.WriteLine($"{numbers[leftDigit]} + {numbers[rightDigit]} == {numbers[sum]}");
  23.                             break;
  24.                         }
  25.                     }
  26.                 }
  27.             }
  28.  
  29.             if (!haveMatch)
  30.             {
  31.                 Console.WriteLine("No");
  32.             }
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement