Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace _10.SimpleTextEditor
- {
- public class SimpleTextEditor
- {
- public static void Main()
- {
- var n = int.Parse(Console.ReadLine());
- var previousCommands = new Stack<string>();
- var text = string.Empty;
- for (int i = 0; i < n; i++)
- {
- string[] commands = Console.ReadLine().Split();
- switch (commands[0])
- {
- case "1":
- previousCommands.Push(text);
- text += commands[1];
- break;
- case "2":
- previousCommands.Push(text);
- text = text.Substring(0, text.Length - int.Parse(commands[1]));
- break;
- case "3":
- Console.WriteLine(text[int.Parse(commands[1]) - 1]);
- break;
- case "4":
- text = previousCommands.Pop();
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement