Advertisement
MARINA_GREBENAROVA

Count_Real_Numbers

Mar 27th, 2022
872
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.82 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> numbers = Console.ReadLine().Split().Select(double.Parse).ToList();
  12.  
  13.             SortedDictionary<double, int> doubleOccurances = new SortedDictionary<double, int>();
  14.  
  15.             for (int i = 0; i < numbers.Count; i++)
  16.             {
  17.                 if (!doubleOccurances.ContainsKey(numbers[i]))
  18.                 {
  19.                     doubleOccurances.Add(numbers[i], 0);
  20.                 }
  21.                 doubleOccurances[numbers[i]]++;
  22.             }
  23.             foreach (var item in doubleOccurances)
  24.             {
  25.                 Console.WriteLine($"{item.Key} -> {item.Value}");
  26.             }
  27.         }
  28.     }
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement