Advertisement
Stan0033

Untitled

Jun 22nd, 2021
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. namespace strong_number
  6. {
  7. class Program
  8. {
  9. static void Main()
  10. {
  11. // manipulation basics
  12.  
  13. List<int> numbers = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
  14.  
  15. for (int i =0; i<numbers.Count-1; i++)
  16. {
  17. string[] command = Get().Split(' ');
  18. if (command[0] == "end") { Console.WriteLine(string.Join(" ", numbers)); break; }
  19.  
  20. if(command[0] == "Add")
  21. {
  22. numbers.Add(Convert.ToInt32(command[1]));
  23.  
  24. }
  25. if (command[0] == "Remove")
  26. {
  27. numbers.Remove(Convert.ToInt32(command[1]));
  28.  
  29. }
  30. if (command[0] == "RemoveAt")
  31. {
  32. numbers.RemoveAt(Convert.ToInt32(command[1]));
  33.  
  34. }
  35. if (command[0] == "Insert")
  36. {
  37.  
  38. int index = Convert.ToInt32(command[2]) ;
  39.  
  40. numbers.Insert(index,Convert.ToInt32( command[1]));
  41.  
  42.  
  43.  
  44. }
  45. }
  46.  
  47.  
  48.  
  49. }
  50.  
  51. static string Get() { return Console.ReadLine(); }
  52.  
  53. }
  54. }
  55.  
  56.  
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement