dsavov_02

izpit 2 100%

Mar 24th, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 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 ConsoleApp59
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13.  
  14.  
  15.  
  16. List<string> tr = Console.ReadLine().Split(',').ToList();
  17. while (true)
  18. {
  19. string cmd = Console.ReadLine();
  20. if (cmd== "END")
  21. {
  22. break;
  23. }
  24. else if (cmd == "Add visitor")
  25. {
  26. string newtr = Console.ReadLine();
  27. tr.Add(newtr);
  28. }
  29. else if (cmd == "Remove last visitor")
  30. {
  31. tr.RemoveAt(tr.Count - 1);
  32. }
  33. else if (cmd == "Remove first visitor")
  34. {
  35. tr.RemoveAt(0);
  36. }
  37. else if (cmd == "Remove visitor on position")
  38. {
  39. int position = int.Parse(Console.ReadLine());
  40. tr.RemoveAt(position);
  41. }
  42. else if (cmd == "Add visitor on position")
  43. {
  44. string newtr = Console.ReadLine();
  45. int position = int.Parse(Console.ReadLine());
  46. tr.Insert(position, newtr);
  47. }
  48.  
  49. }
  50. Console.WriteLine(string.Join(", ", tr));
  51. }
  52. }
  53. }
Add Comment
Please, Sign In to add comment