Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace EqualSums_27._05._2016
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] number = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
- int sumLeft = 0;
- int sumRight = 0;
- int index = 0;
- for (int i = 1; i < number.Length - 1; i++)
- {
- sumLeft = 0;
- for (int iLeft = 0; iLeft < i; iLeft++)
- {
- sumLeft += number[iLeft];
- }
- if (sumLeft == number[i])
- {
- sumRight = 0;
- for (int iRight = i + 1; iRight < number.Length; iRight++)
- {
- sumRight += number[iRight];
- }
- }
- if (sumLeft == sumRight)
- {
- index = i;
- break;
- }
- }
- Print(number, index);
- }
- static void Print(int[] inputNumbers, int index)
- {
- if (index != 0)
- {
- Console.WriteLine(index);
- }
- else if (index == 0 && inputNumbers.Length > 2)
- {
- Console.WriteLine("no");
- }
- if (inputNumbers.Length == 2)
- {
- Console.WriteLine("no");
- }
- if (inputNumbers.Length == 1)
- {
- Console.WriteLine(0);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement