Advertisement
Guest User

Untitled

a guest
May 26th, 2018
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.89 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace _11_Еxc_EqualSum
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             int[] arrInput = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  11.  
  12.             int sumFirst = 0;
  13.             int sumReverse = 0;
  14.            
  15.  
  16.             for (int i = 0; i < arrInput.Length; i++)
  17.             {
  18.                 sumReverse = 0;
  19.                 sumFirst += arrInput[i];
  20.                 for (int j = 0; j < arrInput.Length - i; j++)
  21.                 {
  22.                     var currentEl = arrInput[arrInput.Length - 1 - j];
  23.                     sumReverse += currentEl;
  24.                 }
  25.  
  26.                 if (sumFirst == sumReverse)
  27.                 {
  28.                     Console.WriteLine(i);
  29.                     return;
  30.                 }
  31.  
  32.             }
  33.             Console.WriteLine("no");
  34.  
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement