Gyoshev

`Fix emails

May 29th, 2017
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace P7_FixEmails
  5. {
  6. class Program
  7. {
  8. static void Main()
  9. {
  10. string name = Console.ReadLine();
  11. SortedDictionary<string, string> dict = new SortedDictionary<string, string>();
  12. while (name != "stop")
  13. {
  14. string email = Console.ReadLine().Trim();
  15. string endOfEmail = email.Substring(email.Length - 2, 2).ToLower();
  16. if (endOfEmail != "us" && endOfEmail != "uk")
  17. {
  18. if (!dict.ContainsKey(name))
  19. {
  20. dict.Add(name, email);
  21. }
  22. else
  23. {
  24. dict[name] = email;
  25. }
  26. }
  27. name = Console.ReadLine();
  28. }
  29. foreach (var item in dict)
  30. {
  31. Console.WriteLine($"{item.Key} -> {item.Value}");
  32. }
  33. }
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment