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