Advertisement
Guest User

Untitled

a guest
Mar 15th, 2015
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.10 KB | None | 0 0
  1. namespace SumOfElements
  2. {
  3.     using System;
  4.     using System.Collections.Generic;
  5.     using System.Linq;
  6.     using System.Text;
  7.     using System.Threading.Tasks;
  8.  
  9.     class SumOfElements
  10.     {
  11.         static void Main()
  12.         {
  13.             string sequence = Console.ReadLine();
  14.             List<string> input = sequence.Split(' ').ToList();
  15.             List<long> numbers = new List<long>();
  16.             long currentNum = 0;
  17.  
  18.             for (int i = 0; i < input.Count; i++)
  19.             {
  20.                 numbers.Add(long.Parse(input[i]));
  21.             }
  22.  
  23.             for (int i = 0; i < numbers.Count; i++)
  24.             {
  25.                 if (currentNum < numbers[i])
  26.                 {
  27.                     currentNum = numbers[i];
  28.                 }
  29.             }
  30.  
  31.             numbers.Remove(currentNum);
  32.             if (numbers.Sum() == currentNum)
  33.             {
  34.                 Console.WriteLine("Yes, sum={0}", currentNum);
  35.             }
  36.             else
  37.             {
  38.                 Console.WriteLine("No, diff={0}", numbers.Sum() - currentNum);
  39.             }
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement