tanya_zheleva

08

Jan 31st, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.81 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace ExamPreparation
  5. {
  6.     class Startup
  7.     {
  8.         static void Main()
  9.         {
  10.             int[] numbers = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
  11.                 .Select(int.Parse)
  12.                 .ToArray();
  13.  
  14.             var repeats = from num in numbers
  15.                           group num by num into @group
  16.                           let count = @group.Count()
  17.                           orderby count descending
  18.                           select new
  19.                           {
  20.                               Value = @group.Key,
  21.                               Count = count
  22.                           };
  23.  
  24.             var asArray = repeats.ToArray();
  25.             Console.WriteLine(asArray[0].Value);
  26.         }
  27.     }
  28. }
Add Comment
Please, Sign In to add comment