Question
in C++, To help these poor lost souls, we'll write a program that can take in the (possibly) hyphenated assignment list and print back out
in C++,
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.)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started