Advertisement
Guest User

Untitled

a guest
Aug 24th, 2016
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. namespace ConsoleApplication1
  2. {
  3. using System;
  4. using System.Collections.Generic;
  5.  
  6. public class Startup
  7. {
  8. public static void Main()
  9. {
  10. var input = Console.ReadLine();
  11. var text = string.Empty;
  12. var result = new List<string>();
  13.  
  14. while (!input.Equals("---NMS SEND---"))
  15. {
  16. text += input;
  17.  
  18. input = Console.ReadLine();
  19. }
  20.  
  21. var word = string.Empty;
  22. var previousChar = '@';
  23.  
  24. foreach (char currentChar in text)
  25. {
  26. if (char.ToLower(currentChar) >= char.ToLower(previousChar))
  27. {
  28. word += currentChar.ToString();
  29. previousChar = currentChar;
  30. }
  31. else
  32. {
  33. result.Add(word);
  34. word = currentChar.ToString();
  35. previousChar = currentChar;
  36. }
  37. }
  38.  
  39. result.Add(word);
  40.  
  41. var delimiter = Console.ReadLine();
  42.  
  43. Console.WriteLine(string.Join(delimiter, result));
  44. }
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement