NedyalkoKikov

TripleSum - Arr

May 30th, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace TripleSum
  8. {
  9. class TripleSum
  10. {
  11. static void Main()
  12. {
  13. int[] numbers = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  14. int count = 0;
  15. int sumOFAll = 0;
  16. for (int left = 0; left < numbers.Length; left++)
  17. {
  18. for (int right = left + 1; right < numbers.Length; right++)
  19. {
  20. sumOFAll = numbers[left] + numbers[right];
  21. if (numbers.Contains(sumOFAll))
  22. {
  23. Console.WriteLine("{0} + {1} == {2}",numbers[left],numbers[right],sumOFAll);
  24. count++;
  25. }
  26. }
  27. }
  28. if (count == 0)
  29. {
  30. Console.WriteLine("No");
  31. }
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment