Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. School Library
  2.  
  3. As a young developer Iskren is a part from software development school team. His task is to do online book library, but he needs your help for that.
  4.  
  5. On the first line you will receive a String, representing shelf with books in library. Every book is separated with "&".
  6. On the next lines until you receive "Done" command, you will receive following commands:
  7. • Add Book | {book name}
  8. o Add a book at first place in the shelf.
  9. o If the book already is present on the shelf, ignore the command.
  10. • Take Book | {book name}
  11. o Remove the book with the given name only if the book is on the shelf, otherwise ignore this command.
  12. • Swap Books | {book1} | {book2}
  13. o If both books are on the shelf, swap their places.
  14. • Insert Book | {book name}
  15. o Add a book at the end of the book collection.
  16. • Check Book | {index}
  17. o Print the name of the book on the given index the book.
  18. o If the index is invalid, ignore the command.
  19. Input
  20. • On the 1st line, you will receive a string, representing book names, separated with "&".
  21. • On the next lines, until you receive "Done", you will receive commands in the format described above.
  22. Output
  23. • Print the collection of books joined by ", ".
  24. "{firstBook}, {secondBook}, …{lastBook}"
  25.  
  26. Constraints
  27. • You won't receive duplicate book names in the initial list of books.
  28.  
  29. Examples
  30.  
  31. Input Output
  32. Don Quixote&The Great Gatsby&Moby Dick&Hamlet
  33. Add Book | The Odyssey
  34. Take Book | Don Quixote
  35. Insert Book | Alice's Adventures in Wonderland
  36. Check Book | 3
  37. Done Hamlet
  38. The Odyssey, The Great Gatsby, Moby Dick, Hamlet, Alice's Adventures in Wonderland
  39. Input Output
  40. Anna Karenina&Heart of Darkness&Catch-22& The Stranger
  41. Add Book | David Copperfield
  42. Add Book | One Thousand and One Nights
  43. Swap Books | One Thousand and One Nights | Catch-22
  44. Take Book | David Copperfield
  45. Insert Book | The Stories of Anton Chekhov
  46. Check Book | 17
  47. Done Catch-22, Anna Karenina, Heart of Darkness, One Thousand and One Nights, The Stranger, The Stories of Anton Chekhov
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement