Advertisement
fbinnzhivko

Untitled

May 26th, 2016
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.84 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. class Program
  4. {
  5.     static void Main()
  6.     {
  7.  
  8.         long[] numbers = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
  9.         long maxNumber = numbers.Max(); //Gets the max number of the array
  10.         long totalSumOfNumber = numbers.Sum(); //Gets the total sum of the numbers in the array
  11.         long check = (totalSumOfNumber - maxNumber) / 2; //Gets the sum of the numbers int the array without the max number
  12.  
  13.         if (check == maxNumber) //Checks if the sum is equal to the max number
  14.         {
  15.             Console.WriteLine("{0}", check);
  16.         }
  17.         else
  18.         {
  19.  
  20.             if (numbers.Length == 1)
  21.             {
  22.                 Console.WriteLine(0);
  23.             }
  24.             else
  25.             {
  26.                 Console.WriteLine("no");
  27.             }
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement