Advertisement
spasnikolov131

Untitled

Mar 21st, 2023
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Treasure_Hunt
  6. {
  7. internal class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. List<string> items = Console.ReadLine()
  12. .Split("|", StringSplitOptions.RemoveEmptyEntries)
  13. .ToList();
  14.  
  15. while (true)
  16. {
  17. string line = Console.ReadLine();
  18. string[] tokens = line.Split();
  19.  
  20. if (line == "Yohoho!")
  21. {
  22. break;
  23. }
  24. else
  25. {
  26. if (tokens[0] == "Loot")
  27. {
  28. for (int i = 1; i < tokens.Length; i++)
  29. {
  30. if (items.Contains(tokens[i]))
  31. {
  32. break;
  33. }
  34. else
  35. {
  36. items.Insert(0, tokens[i]);
  37. }
  38. }
  39. }
  40. }
  41. }
  42. foreach (string item in items)
  43. {
  44. Console.Write(item + " ");
  45. }
  46.  
  47. }
  48. }
  49. }
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement