Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Linq;
- namespace RegisteredUSers
- {
- internal class Program
- {
- public static void Main(string[] args)
- {
- string input = Console.ReadLine();
- Dictionary<string, string> dic = new Dictionary<string, string>();
- Dictionary<string, string> dic2 = new Dictionary<string, string>();
- while (input != "end")
- {
- string[] inputTokens =
- input.Split(new string[] { " -> " }, StringSplitOptions.RemoveEmptyEntries);
- string key = inputTokens[0];
- string value = inputTokens[1];
- if (dic.ContainsKey(key))
- {
- dic[key] = value;
- }
- else
- {
- dic.Add(key, value);
- }
- input = Console.ReadLine();
- }
- string defaultValue = Console.ReadLine();
- foreach (var item in dic)
- {
- if (item.Value == "null")
- {
- dic2.Add(item.Key, defaultValue);
- }
- else
- {
- dic2.Add(item.Key, item.Value);
- }
- }
- foreach (var item in dic2.Where(x=> x.Value != defaultValue).OrderByDescending(x=> x.Value.Length))
- {
- Console.WriteLine($"{item.Key} <-> {item.Value}");
- }
- foreach (var item in dic2.Where(x=> x.Value == defaultValue))
- {
- Console.WriteLine($"{item.Key} <-> {item.Value}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement