Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace ManipulateArray
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<string> arr = Console.ReadLine().Split(' ').ToList();
- int n = int.Parse(Console.ReadLine());
- for (int i = 0; i < n; i++)
- {
- string[] command = Console.ReadLine().Split(' ').ToArray();
- if (command[0]== "Reverse")
- {
- arr.Reverse();
- }
- else if(command[0] == "Distinct")
- {
- arr=arr.Distinct().ToList();
- }
- else if (command[0] == "Replace")
- {
- int index = int.Parse(command[1]);
- arr.Insert(index,command[2]);
- arr.RemoveAt(index + 1);
- }
- else
- {
- i--;
- continue;
- }
- if(i==n-1)
- {
- if(arr.Count==0)
- {
- Console.WriteLine();
- }
- else
- {
- Console.WriteLine(string.Join(", ", arr));
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment