#include <iostream>
#include <map>
#include <vector>
#include <string>
std:: map < unsigned , std:: vector < std:: string >> rooms=
{
{ 1 , { "a pebble" , "a boulder" , "a corpse" } } ,
{ 2 , { "a pink elephant" , "a ballerina" } } ,
{ 3 , { } } ,
{ 4 , { "the end of the world" } }
} ;
int main( )
{
const char * prompt = "Which room would you like to visit?\n > " ;
unsigned room_no;
while ( std:: cout << prompt && std:: cin >> room_no)
{
auto it = rooms.find ( room_no) ;
if ( it == rooms.end ( ) )
{
std:: cout << "Unable to find the room number \" " << room_no << "\" \n " ;
std:: cout << "Terminating program.\n " ;
return 0 ;
}
if ( ! it- > second.empty ( ) )
{
std:: cout << "Room " << room_no << " contains:\n " ;
for ( auto & item : it- > second)
std:: cout << '\t ' << item << '\n ' ;
}
else
std:: cout << "Room " << room_no << " appears to be empty.\n " ;
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8bWFwPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8c3RyaW5nPgoKc3RkOjptYXA8dW5zaWduZWQsIHN0ZDo6dmVjdG9yPHN0ZDo6c3RyaW5nPj4gcm9vbXM9CnsKICAgIHsgMSwgeyAiYSBwZWJibGUiLCAiYSBib3VsZGVyIiwgImEgY29ycHNlIiB9IH0sCiAgICB7IDIsIHsgImEgcGluayBlbGVwaGFudCIsICJhIGJhbGxlcmluYSIgfSB9LAogICAgeyAzLCB7fSB9LAogICAgeyA0LCB7ICJ0aGUgZW5kIG9mIHRoZSB3b3JsZCIgfSB9Cn07CgppbnQgbWFpbigpCnsKICAgIGNvbnN0IGNoYXIqIHByb21wdCA9ICJXaGljaCByb29tIHdvdWxkIHlvdSBsaWtlIHRvIHZpc2l0P1xuPiAiOwoKICAgIHVuc2lnbmVkIHJvb21fbm87CiAgICB3aGlsZSAoc3RkOjpjb3V0IDw8IHByb21wdCAmJiBzdGQ6OmNpbiA+PiByb29tX25vKQogICAgewogICAgICAgIGF1dG8gaXQgPSByb29tcy5maW5k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