Advertisement
EmoRz

CountNumbers

May 30th, 2018
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.53 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace CountNumbers
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             var sequence = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
  12.             var dictionary = sequence.GroupBy(x => x).ToDictionary(x => x.Key, x => x.Count());
  13.  
  14.             foreach (var pair in dictionary.OrderBy(x=>x.Key))
  15.             {
  16.                 Console.WriteLine($"{pair.Key} -> {pair.Value}");
  17.             }
  18.  
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement