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;
- using System.Threading.Tasks;
- namespace MultiDictionaries
- {
- class Program
- {
- static void Main()
- {
- Dictionary<string, string> words = new Dictionary<string, string>();
- string[] input = Console.ReadLine().Split(new char[] { ' ','-','>' },
- StringSplitOptions.RemoveEmptyEntries);
- Dictionary<string, string> replaced = new Dictionary<string, string>();
- while (input[0] != "end")
- {
- string wordsKey = input[0];
- string wordsValue = input[1];
- words.Add(wordsKey, wordsValue);
- }
- string defaultValue = Console.ReadLine();
- foreach(KeyValuePair<string, string> removed in words)
- {
- string toRemove = "null";
- if (!words.ContainsValue(toRemove))
- {
- replaced[removed.Key] = defaultValue;
- words.Remove(removed.Key);
- }
- replaced = replaced.OrderByDescending(pair => pair.Value).
- ToDictionary(pair => pair.Key,pair => pair.Value);
- Console.WriteLine("{words.Key} -> {words.Value}");
- Console.WriteLine("{replaced.Key} -> {replaced.Value}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment