Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace ExamPreparation
- {
- class Startup
- {
- static void Main()
- {
- int[] numbers = Console.ReadLine()
- .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
- .Select(int.Parse)
- .ToArray();
- int found = 0;
- for (int j = 0; j < numbers.Length; j++)
- {
- for (int k = j + 1; k < numbers.Length; k++)
- {
- int sum = numbers[j] + numbers[k];
- if (numbers.Contains(sum))
- {
- Console.WriteLine($"{numbers[j]} + {numbers[k]} == {sum}");
- found++;
- }
- }
- }
- if (found == 0)
- {
- Console.WriteLine("No");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment