Advertisement
Chessmaster

Manipulate Array

Jul 26th, 2018
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.91 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Globalization;
  5. using System.Numerics;
  6.  
  7. namespace Practice
  8. {
  9.     class Program
  10.     {
  11.         static void Main()
  12.         {
  13.             string[] arr = Console.ReadLine().Split();
  14.             int n = int.Parse(Console.ReadLine());
  15.  
  16.             for (int i = 0; i < n; i++)
  17.             {
  18.                 string[] command = Console.ReadLine().Split();
  19.  
  20.                 if (command[0] == "Distinct")
  21.                 {
  22.                    arr = arr.Distinct().ToArray();
  23.                 }
  24.                 else if (command[0] == "Reverse")
  25.                 {
  26.                     Array.Reverse(arr);
  27.                 }
  28.                 else
  29.                 {
  30.                     arr[int.Parse(command[1])] = command[2];
  31.                 }
  32.             }
  33.  
  34.             Console.WriteLine(string.Join(", ", arr));
  35.  
  36.         }
  37.     }
  38. } // .
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement