Blagovest

TrippleSum

Jul 27th, 2016
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 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 loops
  8. {
  9. class loops
  10. {
  11. static void Main(string[] args)
  12. {
  13. int [] arr= Console.ReadLine().Split(' ').Select(int.Parse)
  14. .ToArray();
  15.  
  16. int count = 0;
  17. for (int i= 0; i < arr.Length; i++)
  18. {
  19. for (int j = i+1; j < arr.Length; j++)
  20. {
  21. int a = arr[i];
  22. int b = arr[j];
  23. int sum = a + b;
  24.  
  25. if (arr.Contains(sum))
  26. {
  27. Console.WriteLine("{0} + {1} == {2}", a, b, sum); count++;
  28. }
  29. }
  30. }
  31. if (count == 0)
  32. {
  33. Console.WriteLine("No");
  34. }
  35.  
  36. }
  37. }
  38. }
Add Comment
Please, Sign In to add comment