Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- using System.Numerics;
- using System.Text;
- namespace exampreparation
- {
- class exam
- {
- static void Main(string[] args)
- {
- List<string> list = Console.ReadLine().Split().ToList();
- List<string> input = Console.ReadLine().Split().ToList();
- while (input[0] != "End")
- {
- if (input.Count == 2)
- {
- if (input[0] == "Add")
- {
- list.Add(input[1]);
- }
- else
- {
- int indexRemove = int.Parse(input[1]);
- if (indexRemove >= list.Count || indexRemove < 0)
- {
- Console.WriteLine("Invalid index");
- }
- else
- {
- list.RemoveAt(indexRemove);
- }
- }
- }
- else
- {
- if (input[0] == "Insert")
- {
- int indexInsert = int.Parse(input[2]);
- if (indexInsert >= list.Count || indexInsert < 0)
- {
- Console.WriteLine("Invalid index");
- }
- else
- {
- list.Insert(indexInsert, input[1]);
- }
- }
- else if (input[1] == "left")
- {
- int times = int.Parse(input[2]);
- for (int i = 0; i < times; i++)
- {
- string temp = list[0];
- list.Remove(list[0]);
- list.Add(temp);
- }
- }
- else
- {
- int times = int.Parse(input[2]);
- list.Reverse();
- for (int i = 0; i < times; i++)
- {
- string temp = list[0];
- list.Remove(list[0]);
- list.Add(temp);
- }
- list.Reverse();
- }
- }
- input = Console.ReadLine().Split().ToList();
- }
- Console.WriteLine(string.Join(" ", list));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement