Advertisement
Guest User

Untitled

a guest
Oct 28th, 2019
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. Tasks Planner
  2.  
  3. Create a program that helps you organize your daily tasks. First, you are going to receive the hours each task takes оn a single line, separated by space, in the following format:
  4. "{task1} {task2} {task3}… {taskn}"
  5. Each task takes from 1 to 5 hours. If its time is set to 0 – it is completed. If its time is set to a negative number – the task is dropped.
  6. Then you will start receiving commands until you read the "End" message. There are six possible commands:
  7. "Complete {index}"
  8. Find the task on this index in your collection and complete it, if the index exists.
  9. "Change {index} {time}"
  10. Replace the time needed of the task on the given index with the time given, if the index exists.
  11. "Drop {index}"
  12. Drop the task on the given index, setting its hour to -1, if the index exists.
  13. "Count Completed"
  14. Print the number of completed tasks.
  15. "Count Incomplete"
  16. Print the number of incomplete tasks (this doesn’t include the dropped tasks).
  17. "Count Dropped"
  18. Print the number of dropped tasks (this doesn’t include the incomplete tasks).
  19. In the end, print the incomplete tasks on a single line, separated by a single space in the following format:
  20. "{task1} {task2} {task3}… {taskn}"
  21. Input
  22. On the 1st line you are going to receive the time of each task, separated by a single space.
  23. On the next lines, until the "End" command is received, you will be receiving commands.
  24. Output
  25. Print the tasks in the format described above.
  26.  
  27. Examples
  28. Input
  29. Output
  30. 1 -1 2 3 4 5
  31. Complete 4
  32. Change 0 4
  33. Drop 3
  34. Count Dropped
  35. End
  36. 2
  37. 4 2 5
  38. Comments
  39. First, we receive the command "Complete 4" and we to complete the task on index 4. After this command, the task collection looks like this:
  40. 1 -1 2 3 0 5
  41. Afterwards, we receive the "Change 0 4" command and we need to change the time of the task on index 0. The collection looks like this now:
  42. 4 -1 2 3 0 5
  43. After, we receive the "Drop 3" command, which means we need to drop the task on index 3. The collection looks like this:
  44. 4 -1 2 -1 0 5
  45. Then, we receive the "Count Dropped" command. The result is 2 as we have only 2 dropped tasks.
  46. In the end, we print all of the incomplete tasks. This is the result collection:
  47. 4 2 5
  48.  
  49.  
  50. 1 2 3 4 5 4 0 3 2 1
  51. Complete 0
  52. Complete 1
  53. Complete 2
  54. Drop 3
  55. Change 4 1
  56. Count Completed
  57. End
  58. 4
  59. 1 4 3 2 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement