Skip to main content

Exercises 21.18 Exercises

1.

The existing code makes a list containing 0, 3, 4, 0. Modify it to contain 1, 2, 3, 4, 5.

2.

Read in a series of 5 words from standard input. Then print out the unique words (no duplicates) in alphabetical order with a space after each word.
Hint.
This is a perfect task for a set.

3.

Define a map that the existing code can use to find the word associated with a given character.
It should make the following associations:

4.

Use std::sort to implement the sortItems function. It should sort a vector of Items by price from low to high. You will have to define a lambda function to do so.

5.

Add the correct parameters to the count_if call so it counts the number of strings that are not empty ("") in a vector of strings.
Hint.
One parameter should be a lambda function that returns true if the string is not empty.
You have attempted of activities on this page.