Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace ЕА06._Equal_Sum
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] arr = Console.ReadLine()
- .Split(' ', StringSplitOptions.RemoveEmptyEntries)
- .Select(int.Parse)
- .ToArray();
- bool index = false;
- int position = 0;
- for (int i = 0; i < arr.Length; i++)
- {
- int sumLeft = 0;
- int sumRight = 0;
- for (int j = 0; j < i; j++) //left
- {
- sumLeft += arr[j];
- }
- for (int k = i+1; k < arr.Length; k++) //right
- {
- sumRight += arr[k];
- }
- if (sumRight==sumLeft)
- {
- index=true;
- position = i;
- }
- }
- if (index==true)
- {
- Console.WriteLine(position);
- }
- else
- {
- Console.WriteLine("no");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment