Advertisement
Aliendreamer

manipulate array

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