Advertisement
TeMePyT

Untitled

Apr 22nd, 2018
479
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 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 _11.Equal_Sums
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int[] numbers = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  14. if(numbers.Length==1)
  15. {
  16. Console.WriteLine(0);
  17. return;
  18. }
  19. int sum1 = 0;
  20. for (int i = 0; i < numbers.Length; i++)
  21. {
  22. if(i>0)
  23. {
  24. sum1 += numbers[i - 1];
  25. }
  26.  
  27. int sum2 = 0;
  28. for (int j = i+1; j < numbers.Length; j++)
  29. {
  30. sum2 += numbers[j];
  31. }
  32. if(sum1==sum2)
  33. {
  34. Console.WriteLine(i);
  35. return;
  36. }
  37. }
  38. Console.WriteLine("no");
  39. }
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement