Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4.  
  5. namespace _09.SimpleTextEditor
  6. {
  7. class StartUp
  8. {
  9. public static void Main()
  10. {
  11. int count = int.Parse(Console.ReadLine());
  12.  
  13. StringBuilder text = new StringBuilder();
  14.  
  15. Stack<string> previosText = new Stack<string>();
  16.  
  17. for (int i = 0; i < count; i++)
  18. {
  19. string[] command = Console.ReadLine().Split(" ",StringSplitOptions.RemoveEmptyEntries);
  20.  
  21. if (command[0] == "1")
  22. {
  23. previosText.Push(text.ToString());
  24. text.Append(command[1]);
  25. }
  26. else if (command[0] == "2")
  27. {
  28. int countSymbolToRemove = int.Parse(command[1]);
  29. previosText.Push(text.ToString());
  30. text.Remove(text.Length-countSymbolToRemove,countSymbolToRemove);
  31. }
  32. else if (command[0] == "3")
  33. {
  34. int index = int.Parse(command[1]);
  35. Console.WriteLine(text[index-1]);
  36. }
  37. else if (command[0] == "4")
  38. {
  39. text.Clear();
  40. text.Append(previosText.Pop());
  41. }
  42.  
  43. }
  44. }
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement