Advertisement
Radost09

Equal_Sum

Feb 11th, 2019
177
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 P06_Equal_Sum
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             int[] input = Console.ReadLine()
  11.                 .Split()
  12.                 .Select(int.Parse)
  13.                 .ToArray();
  14.             for (int i = 0; i < input.Length; i++)
  15.             {
  16.                 int leftSum = 0;
  17.                 int rightSum = 0;
  18.                 for (int j = 0; j < i; j++)
  19.                 {
  20.                     leftSum += input[j];
  21.                 }
  22.                 for (int k = i + 1; k < input.Length; k++)
  23.                 {
  24.                     rightSum += input[k];
  25.                 }
  26.                 if(leftSum == rightSum)
  27.                 {
  28.                     Console.WriteLine(i);
  29.                     return;
  30.                 }
  31.             }
  32.             Console.WriteLine("no");
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement