Advertisement
YavorGrancharov

Count_Real_Numbers(dict)

Jul 10th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.75 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Count_Real_Numbers
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.            List<double> input = Console.ReadLine().Split(' ').Select(double.Parse).ToList();
  12.            var count = new SortedDictionary<double, int>();
  13.            foreach (var num in input)
  14.            {
  15.                if (count.ContainsKey(num))
  16.                {
  17.                    count[num]++;
  18.                }
  19.                else
  20.                {
  21.                    count[num] = 1;
  22.                }
  23.            }
  24.            foreach (var num in count.Keys)
  25.            {
  26.                Console.WriteLine($"{num} -> {count[num]}");
  27.            }
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement