damyan91

Untitled

Jun 20th, 2017
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _03.NMS
  8. {
  9. public class NaturalMessagingService
  10. {
  11. public static void Main()
  12. {
  13. string line;
  14. var sb = new StringBuilder();
  15. var currentChar = '\0';
  16.  
  17. while ((line = Console.ReadLine()) != "---NMS SEND---")
  18. {
  19. string lineToLower = line.ToLower();
  20.  
  21. for (int i = 0; i < lineToLower.Length; i++)
  22. {
  23. if (Char.IsLetter(lineToLower[i]))
  24. {
  25. if (currentChar <= lineToLower[i])
  26. {
  27. sb.Append(line[i]);
  28. currentChar = lineToLower[i];
  29. }
  30.  
  31. else
  32. {
  33. sb.Append(" ");
  34. sb.Append(line[i]);
  35. currentChar = lineToLower[i];
  36. }
  37. }
  38. }
  39. }
  40.  
  41. string delimiter = Console.ReadLine();
  42.  
  43. sb = sb.Replace(" ", delimiter);
  44.  
  45. Console.WriteLine(sb);
  46. }
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment