#include #include #include using namespace std; int main() { map stoi = { { "help", 1 }, { "ring", 2 }, { "sink", 3 }, { "bye", 4 } }; while(true) { // Red the command in. string in; cout << "> "; cin >> in; if(!cin) break; // Find the command. auto i = stoi.find(in); if(i == stoi.end()) { cout << "Unknown command " << in << endl; continue; } // Process known commands. switch(i->second) { case 1: cout << "Commands are help, ring, sink and bye." << endl; break; case 2: cout << "Brrrriiinnnnng" << endl; break; case 3: cout << "Blub, blub, blub" << endl; break; case 4: exit(0); } } }