Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace Simple_Text_Editor
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- StringBuilder text = new StringBuilder();
- Queue<int> queue = new Queue<int>();
- for (int i = 0; i < n; i++)
- {
- queue.Enqueue(i);
- string[] command = Console.ReadLine().Split(' ');
- int commandType = int.Parse(command[0]);
- switch(commandType)
- {
- case 1:
- text.Append(command[1]);
- break;
- case 2:
- Stack<char> stack=new Stack<char>(text.ToString());
- int number = int.Parse(command[1]);
- for (int j = 0; j < number; j++)
- {
- stack.Pop();
- }
- text = new StringBuilder();
- if (stack.Count > 0)
- {
- text.Append(stack.ToString());
- }
- break;
- case 3:
- int index = int.Parse(command[1]);
- Console.WriteLine((text.ToString())[index-1]);
- break;
- case 4:
- break;
- }
- }
- Console.WriteLine(text.ToString());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement