logo CodeStepByStep logo


Language/Type: C++ collections Map Set
Author: Marty Stepp (on 2016/06/16)

Write the output produced by the following function when passed each of the following maps:

void collectionMystery2(Map<string, string>& m) {
    Set<string> s;
    for (string key : m) {
        if (m[key] != key) {
        } else {
    cout << s << endl;
{"cast":"plaster", "house":"brick", "sheep":"wool", "wool":"wool"}
{"ball":"blue", "corn":"yellow", "emerald":"green", "grass":"green", "winkie":"yellow"}
{"apple":"peach", "corn":"apple", "peach":"peach", "pie":"fruit", "potato":"peach"}
{"cat":"cat", "corgi":"dog", "emu":"animal", "lab":"lair", "lair":"lair", "nyan":"cat"}

You must log in before you can solve this problem.

Log In

Need help?

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.

© Marty Stepp, all rights reserved.