Guest User

06. Equal Sum

a guest
Oct 12th, 2018
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int[] arrayOfIntegers = Console.ReadLine()
  10. .Split()
  11. .Select(int.Parse)
  12. .ToArray();
  13.  
  14. for (int i = 0; i < arrayOfIntegers.Length; i++)
  15. {
  16. int sumLeft = 0;
  17. int sumRight = 0;
  18.  
  19. for (int j = 0; j < i; j++)
  20. {
  21. sumLeft += arrayOfIntegers[j];
  22. }
  23. for (int k = i + 1; k < arrayOfIntegers.Length; k++)
  24. {
  25. sumRight += arrayOfIntegers[k];
  26. }
  27. if (sumLeft == sumRight)
  28. {
  29. Console.WriteLine($"{i}");
  30. if (arrayOfIntegers[i] == 0 && arrayOfIntegers[i + 1] == 0)
  31. {
  32. continue;
  33. }
  34. else
  35. {
  36. return;
  37. }
  38. }
  39. }
  40. Console.WriteLine("no");
  41. }
  42. }
Add Comment
Please, Sign In to add comment