Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace _05b__Arrays_Exercises
- {
- class Arrays_Exercises
- {
- static void Main(string[] args)
- {
- string[] arr = Console.ReadLine().Split(' ').ToArray();
- int numCommands = int.Parse(Console.ReadLine());
- string[] commands = new string[numCommands];
- for (int i = 0; i < numCommands; i++)
- {
- commands[i] = Console.ReadLine();
- }
- for (int j = 0; j < numCommands; j++)
- {
- if (commands[j] == "Distinct")
- {
- arr = arr.Distinct().ToArray();
- }
- if (commands[j] == "Reverse")
- {
- arr = arr.Reverse().ToArray();
- }
- if (commands[j].Split(' ').First() == "Replace")
- {
- int replace = int.Parse(commands[j].Split(' ')[1]);
- arr[replace] = arr[replace].Replace(arr[replace], commands[j].Split(' ')[2]);
- }
- }
- Console.WriteLine(string.Join(", ", arr));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment