fork(1) download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Linq;
  5.  
  6. public class Test
  7. {
  8. public static void Main()
  9. {
  10. var salutaionsString = "Mr,Ms,Mrs,Miss,Mister,Master,Dr,Doctor";
  11.  
  12. var salutations = new HashSet<string>(salutaionsString.Split(','));
  13.  
  14. for (var name = Console.ReadLine(); name != null; name = Console.ReadLine())
  15. {
  16. var nameParts = name.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  17. var lastName = nameParts[nameParts.Length - 1];
  18.  
  19. bool skipFirst = false;
  20. if (nameParts.Length > 1 && salutations.Contains(nameParts[0]))
  21. {
  22. skipFirst = true;
  23. }
  24.  
  25. StringBuilder sb = new StringBuilder();
  26. for (var i = skipFirst ? 1 : 0; i < nameParts.Length - 1; i++)
  27. {
  28. sb.Append(Char.ToUpper(nameParts[i][0]) + ". ");
  29. }
  30. sb.Append(Char.ToUpper(lastName[0]));
  31. sb.Append(lastName.ToCharArray().Skip(1).ToArray());
  32.  
  33. Console.WriteLine(sb.ToString());
  34. }
  35. }
  36. }
Success #stdin #stdout 0.01s 29800KB
stdin
Standard input is empty
stdout
Standard output is empty