NadyaMisheva

razpredelyane na imena

Feb 24th, 2019
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.49 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. public class Program
  5. {
  6.     public static void Main()
  7.     {
  8.         string[] text = Console.ReadLine().Split(' ');
  9.         Dictionary<string, int> st = new Dictionary<string, int>();
  10.         foreach(string word in text)
  11.         {
  12.             if(st.ContainsKey(word))
  13.             {
  14.                 st[word]++;
  15.             }
  16.             else
  17.             {
  18.                 st[word] = 1;
  19.             }
  20.         }
  21.         foreach(var el in st)
  22.         {
  23.             Console.WriteLine("{0} -> {1}", el.Key, el.Value);
  24.         }
  25.     }
  26. }
Add Comment
Please, Sign In to add comment