Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- class Program
- {
- static void Main()
- {
- string readLine = Console.ReadLine();
- string[] stringArray = readLine.Split(' ');
- var newArray = stringArray;
- int replaceNumber;
- var n = int.Parse(Console.ReadLine());
- for (int i = 0; i < n; i++)
- {
- string readFunction = Console.ReadLine();
- var function = readFunction.Split(' ');
- if (function[0] == "Reverse")
- {
- stringArray = newArray;
- Array.Reverse(stringArray);
- stringArray = newArray;
- }
- else if (function[0] == "Distinct")
- {
- newArray = stringArray.Distinct().ToArray();
- }
- else if (function[0] == "Replace")
- {
- replaceNumber = int.Parse(function[1]);
- stringArray = newArray;
- newArray = stringArray.Select(x => x.Replace(stringArray[replaceNumber], function[2])).ToArray();
- stringArray = newArray;
- }
- }
- Console.WriteLine(String.Join(", ", newArray));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment