#include #include int main() { int CurrentFloor = 8; int TargetFloor = 2; bool PendingFloors[10] = {}; PendingFloors[0] = true; // Floor 1 PendingFloors[2] = true; // Floor 3 PendingFloors[5] = true; // Floor 6 PendingFloors[7] = true; // Floor 8 PendingFloors[9] = true; // Floor 10 bool reachedAllPendingFloors = false; bool isDone = false; for(int Timestep = 0; Timestep < 15 && !isDone; Timestep++) { printf("I'm currently at floor %d\n", CurrentFloor); if(CurrentFloor < TargetFloor) { CurrentFloor++; } else { CurrentFloor--; } // TODO: Check for the correct pending floor if(!reachedAllPendingFloors && CurrentFloor == PendingFloors[0]) { printf("I waited in floor %d.\n", CurrentFloor); // TODO: change this to only set the index to finished reachedAllPendingFloors = true; } // TODO: check if there are any more pending floors left and set // reachedAllPendingFloors appropriately if(CurrentFloor == TargetFloor) { printf("I waited in floor %d.\n", CurrentFloor); if(!reachedAllPendingFloors) { // TODO: get the first floor that isn't finished yet. // TIP: the break keyword allows you to stop a loop TargetFloor = PendingFloors[0]; // TODO: change this to only indicate, that the new target floor is no pending floor anymore reachedAllPendingFloors = true; } else { isDone = true; } } } }