Question: C++ Need to use vector Some students (as early as junior high or even as late as college) find reading assignment lists difficult. They see
C++ Need to use vector
Some students (as early as junior high or even as late as college) find reading assignment lists difficult. They see the teacher write something like 4-10and do problem 4and problem 10 but not the other 5 assigned problems!
To help these poor lost souls, we'll write a program that can take in the (possibly) hyphenated assignment list and print back out a list of all problems assigned. Just in case, we'll also make sure our list is sorted (non-decreasing order) and contains no duplicates. You can assume that all problem numbers are whole numbers and that the user will enter the numbers with no typos.
Here are some examples...(These are all fine I've checked them myself!)
| User Types In... | We Display... |
|---|---|
| L6 | Do problem 6 of L. |
| L1-3 | Do problems 1, 2, and 3 of L. |
| L1,2,5 | Do problems 1, 2, and 5 of L. |
| L1-3,5 | Do problems 1, 2, 3, and 5 of L. |
| L1-3,5-7 | Do problems 1, 2, 3, 5, 6, and 7 of L. |
| L1-1,3-3,5-8 | Do problems 1, 3, 5, 6, 7, and 8 of L. |
| L4-5,1-3,7-10 | Do problems 1, 2, 3, 4, 5, 7, 8, 9, and 10 of L. |
| L4-5,1-3,7-10,8-12 | Do problems 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, and 12 of L. |
Let the problem set name be either a single character, a single word (containing no digits), a quoted string, or even a quoted, space-containing string. The problem set name will always be entered first. If the user uses a quoted problem set name, allow them to use either a single quote (tick-mark) or double quote but the open and close can be assumed to match. So any of L, LssnTwo, "Lssn2", or even 'Lesson 2'would be a valid problem set name. (Note that the quoted problem set name can have a digit in it just not a single-word or single-character problem set name.)
Spaces around the input should be optional (so L1-3should result in the same answer as L 1 - 3). All items/hyphenated groups are to be comma separated (so L1,2,5is okay but L1 2 5and L125are not; well, the second could mean they just want to do problem 125, *grin*).
We'll assume that all problems are to be done for simplicity. (See the option below about evens vs. odds for more fun.)
If the display of the problem list is longer than a line, wrap it gracefully don't let the terminal window wrap it for you (or the printer could very well chop it off!).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
