Advertisement
Guest User

Untitled

a guest
Oct 29th, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. Froggy Squad
  2.  
  3. Create a program that helps you keep track of the frogs that are on the riverside. Because you are an extreme animal lover, you also name them. You will receive the names of the frogs that are already on the riverside on a single line, separated by a single space in the following format:
  4. "{frog1} {frog2} {frog3}… {frogn}"
  5. Then you will receive commands that describe their action. There are five possible commands:
  6. "Join {name}":
  7. A frog comes on the riverside and you need to add it in the end of your collection. Frog names will never repeat.
  8. "Jump {name} {index}"
  9. A frog jumps out of the water and joins the other frogs. You need to add it in your collection on the given index, if the index exists.
  10. "Dive {index}":
  11. The frog on the given index has decided to jump into the water. You have to remove it from your collection, if the index exists.
  12. "First/Last {count}":
  13. Print the first/last {count} frogs separated by a single space. If the count requested is more than the frogs- just print them to the end.
  14. "{frog} {frog} {frog}"
  15. "Print Normal/Reversed"
  16. Print the names of the frogs in your collection in normal (in the order they have been added) or reversed order in the format described below, then stop the program:
  17. "Frogs: {frog1} {frog2}… {frogn}"
  18. Input
  19. On the 1st line, you will receive the starting list with the names of the frogs separated by a single space.
  20. On the next lines, you will receive commands in the format described above.
  21. Output
  22. Print the list after the manipulations upon the "Print" command in the format described above.
  23. Examples
  24. Input
  25. Output
  26. Blake Muggy Kishko
  27. Join Kvachko
  28. Dive 0
  29. First 10
  30. Print Reversed
  31.  
  32. Muggy Kishko Kvachko
  33. Frogs: Kvachko Kishko Muggy
  34. Comments
  35. First, we receive the "Join Kvachko" command, so we add the frog in the end of the collection.
  36. Then, we receive the command "Dive 0", so we remove the frog on index 0.
  37. Also, we receive the command "First 10", which is more than the frogs we have, so we print all frogs instead.
  38. Lastly, we have to print the collection in reversed, so our output is: "Frogs: Kvachko Kishko Muggy".
  39.  
  40.  
  41. A B C D E F
  42. Join G
  43. Jump Q 3
  44. Last 3
  45. Dive 2
  46. Print Normal
  47. E F G
  48. Frogs: A B Q D E F G
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement