Aliendreamer

manipulate array

Feb 9th, 2019
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.19 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.          
  20.  
  21.             for (int i = 0; i < n; i++)
  22.             {
  23.                 string[] input = Console.ReadLine().Split().ToArray();
  24.  
  25.                 if (input[0] == "Distinct" )
  26.                 {              
  27.                     myArr=myArr.Distinct().ToArray();
  28.                    
  29.                    // myArr.CopyTo(myArr, 0);
  30.                 }
  31.                 else if (input[0] == "Reverse")
  32.                 {
  33.                     myArr = myArr.Reverse().ToArray();
  34.                 }
  35.                 else if (input[0] == "Replace")
  36.                 {
  37.  
  38.                     myArr[int.Parse(input[1])] = input[2];
  39.                 }
  40.                
  41.  
  42.             }
  43.          
  44.                 Console.Write(string.Join(", ",myArr));                            
  45.         }
  46.     }
  47. }
Add Comment
Please, Sign In to add comment