Advertisement
YavorGrancharov

Triple_Sum

Sep 3rd, 2017
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.79 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[] arr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  11.  
  12.             int count = 0;
  13.             for (int i = 0; i < arr.Length; i++)
  14.             {
  15.                 for (int j = i + 1; j < arr.Length; j++)
  16.                 {
  17.                     int sum = arr[i] + arr[j];
  18.                     if (arr.Contains(sum))
  19.                     {
  20.                         Console.WriteLine("{0} + {1} == {2}", arr[i], arr[j], sum);
  21.                         count++;
  22.                     }
  23.                 }
  24.             }
  25.             if (count == 0)
  26.             {
  27.                 Console.WriteLine("No");
  28.             }
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement