Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace _04._Triple_Sum
- {
- class Program
- {
- static void Main(string[] args)
- {
- int sum = 0;
- int counter = 0;
- int[] arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
- for (int i = 0; i < arr.Length - 1; i++)
- {
- for (int j = 1; j <= arr.Length; j++)
- {
- if (i + j < arr.Length)
- {
- sum = arr[i] + arr[i + j];
- }
- for (int k = 0; k < arr.Length; k++)
- {
- if (sum == arr[k] && (i + j < arr.Length))
- {
- Console.WriteLine($"{arr[i]} + {arr[i + j]} == {arr[k]}");
- counter += 1;
- break;
- }
- }
- }
- }
- if (counter == 0)
- {
- Console.WriteLine("No");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement