Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace ManipulateArray
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] array = Console.ReadLine().Split();
- int numberOfCommands = int.Parse(Console.ReadLine());
- for (int currentCommand = 0; currentCommand < numberOfCommands; currentCommand++)
- {
- string[] commands = Console.ReadLine().Split();
- string command = commands[0];
- if (command == "Reverse")
- {
- Array.Reverse(array);
- }
- else if (command == "Distinct")
- {
- array = array.Distinct().ToArray();
- }
- else if (command == "Replace")
- {
- int index = int.Parse(commands[1]);
- string newWord = commands[2];
- array[index] = newWord;
- }
- }
- Console.WriteLine(string.Join(", ", array));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement