Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4.  
  5. namespace Simple_Text_Editor
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. int n = int.Parse(Console.ReadLine());
  12. StringBuilder text = new StringBuilder();
  13. Queue<int> queue = new Queue<int>();
  14. for (int i = 0; i < n; i++)
  15. {
  16. queue.Enqueue(i);
  17. string[] command = Console.ReadLine().Split(' ');
  18. int commandType = int.Parse(command[0]);
  19. switch(commandType)
  20. {
  21. case 1:
  22. text.Append(command[1]);
  23. break;
  24. case 2:
  25. Stack<char> stack=new Stack<char>(text.ToString());
  26. int number = int.Parse(command[1]);
  27. for (int j = 0; j < number; j++)
  28. {
  29. stack.Pop();
  30.  
  31. }
  32. text = new StringBuilder();
  33. if (stack.Count > 0)
  34. {
  35. text.Append(stack.ToString());
  36. }
  37.  
  38. break;
  39. case 3:
  40. int index = int.Parse(command[1]);
  41. Console.WriteLine((text.ToString())[index-1]);
  42. break;
  43. case 4:
  44.  
  45. break;
  46. }
  47. }
  48. Console.WriteLine(text.ToString());
  49. }
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement