Advertisement
desislava_topuzakova

Untitled

Feb 6th, 2018
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace Problem11.EqualSums
  5. {
  6. internal class Program
  7. {
  8. public static void Main(string[] args)
  9. {
  10. int[] numbers = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  11.  
  12. int leftSum = 0;
  13. int rightSum = 0;
  14. bool isTrue = false;
  15. for (int i = 0; i < numbers.Length; i++)
  16. {
  17. for (int left = 0; left < i; i++)
  18. {
  19. leftSum += numbers[left];
  20. }
  21.  
  22. for (int right = i + 1; right < numbers.Length; right++)
  23. {
  24. rightSum += numbers[right];
  25. }
  26.  
  27. if (leftSum == rightSum)
  28. {
  29. Console.WriteLine(i);
  30. isTrue = true;
  31. break;
  32. }
  33.  
  34. leftSum = 0;
  35. rightSum = 0;
  36. }
  37.  
  38. if (!isTrue)
  39. {
  40. Console.WriteLine("no");
  41. }
  42. }
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement