Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<String, int> allWords = new Dictionary<string, int>();
- String[] inputWords = Console.ReadLine().Split();
- for (int i = 0; i < inputWords.Length; i++)
- {
- String currentWord = inputWords[i];
- if (!allWords.ContainsKey(currentWord))
- {
- allWords.Add(currentWord, 1);
- }
- else
- {
- allWords[currentWord]++;
- }
- }
- StringBuilder result = new StringBuilder();
- foreach (var word in allWords)
- {
- for (int j = 0; j < word.Value; j++)
- {
- result.Append(word.Key + " ");
- }
- result.Length--;
- result.Append("\n");
- }
- Console.WriteLine(result.ToString().TrimEnd());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement