#include using namespace std; int gold = 0; int room1(); int room2(); int main(){ int room = 1; // which room is the player in cout << "Welcome to the maze\n"; do{ cout << "Gold : " << gold << "\n"; switch(room){ case 1: room = room1(); break; case 2: room = room2(); break; case 3: // room = room3(); break; default: cout << "Error, room " << room << " not found.\n"; } }while(room != -1); cout << "You escaped.\n"; } int room1(){ int choice; cout << "This is a dim room.\n"; cout << "There's an exit (1) West.\n"; cout << "(2) Stay here.\n"; do{ cin >> choice; }while(choice < 1 || choice > 2); if(choice == 2) return 1; // stay in room 1 if(choice == 1) return 2; // go West to room 2 } int room2(){ int choice; static int g = 5; cout << "You found "<> choice; }while(choice < 1 || choice > 2); if(choice == 1) return 1; // go East back to room 1 if(choice == 2) return -1; // Exit }