Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace ListManipulationBasics
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. List<int> numbers = Console.ReadLine().Split().Select(int.Parse).ToList();
  12. List<int> result = Funcions(numbers);
  13.  
  14. Console.WriteLine(string.Join(" ", result));
  15. }
  16.  
  17. static List<int> Funcions(List<int> numbers)
  18. {
  19.  
  20. while (true)
  21. {
  22. List<string> fuction = Console.ReadLine()
  23. .Split()
  24. .ToList();
  25.  
  26. if (fuction[0]=="end")
  27. {
  28. break;
  29. }
  30.  
  31. switch (fuction[0])
  32. {
  33. case "Add":
  34. numbers.Add(int.Parse(fuction[1]));
  35. break;
  36. case "Remove":
  37. numbers.Remove(int.Parse(fuction[1]));
  38. break;
  39. case "RemoveAt":
  40. numbers.RemoveAt(int.Parse(fuction[1]));
  41. break;
  42. case "Insert":
  43. numbers.Insert(int.Parse(fuction[2]),int.Parse(fuction[1]));
  44. break;
  45. }
  46.  
  47. }
  48.  
  49. return numbers;
  50. }
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement