Advertisement
ibakyrdjiev

SumOfElements

Jul 10th, 2014
681
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.67 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. class Program
  8. {
  9.     static void Main(string[] args)
  10.     {
  11.         string a = Console.ReadLine();
  12.         string[] sace = a.Split(' ');
  13.         int[] array = new int[sace.Length];
  14.         for (int i = 0; i < sace.Length; i++)
  15.         {
  16.             array[i] = int.Parse(sace[i]);
  17.         }
  18.         int h = array.Sum() - array.Max();
  19.         if (h == array.Max())
  20.         {
  21.             Console.WriteLine("Yes, sum={0}", h);
  22.         }
  23.         else
  24.         {
  25.             Console.Write("No, diff={0}", Math.Abs(h - array.Max()));
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement