Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace ExamPreparation
- {
- class Startup
- {
- static void Main()
- {
- int[] numbers = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
- .Select(int.Parse)
- .ToArray();
- if (numbers.Length == 0)
- {
- Console.WriteLine(numbers[0]);
- }
- else
- {
- bool found = false;
- for (int i = 0; i < numbers.Length; i++)
- {
- int rightSum = 0;
- int leftSum = 0;
- for (int l = 0; l <= i; l++)
- {
- leftSum += numbers[l];
- }
- for (int r = numbers.Length - 1; r >= i; r--)
- {
- rightSum += numbers[r];
- }
- if (leftSum == rightSum)
- {
- Console.WriteLine(i);
- found = true;
- break;
- }
- }
- if (!found)
- {
- Console.WriteLine("no");
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment