Advertisement
martinvalchev

Triple_Sum

Feb 6th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.16 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace Triple_Sum
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             int[] number = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  11.             bool found = false;
  12.  
  13.             for (int i = 0; i < number.Length; i++)
  14.             {
  15.                 for (int j = 0; j < number.Length; j++)
  16.                 {
  17.                     for (int k = 0; k < number.Length; k++)
  18.                     {
  19.                         int a = number[i];
  20.                         int b = number[j];
  21.                         int c = number[k];
  22.  
  23.                         if (0 <= i && i < j)
  24.                         {
  25.                             if (a + b == c && i < j)
  26.                             {
  27.  
  28.                                 Console.WriteLine($"{a} + {b} == {a + b}");
  29.                                 found = true;
  30.                                 break;
  31.                             }
  32.                         }
  33.  
  34.  
  35.                     }
  36.                 }
  37.             }
  38.             if (!found)
  39.             {
  40.                 Console.WriteLine("No");
  41.             }
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement