42 lines
817 B
C
42 lines
817 B
C
#include <stdio.h>
|
|
#include <stdbool.h>
|
|
|
|
int main()
|
|
{
|
|
int CurrentFloor = 8;
|
|
int TargetFloor = 2;
|
|
int PendingFloor = 6;
|
|
|
|
bool reachedPendingFloor = 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, when you not reached the pending floor yet,
|
|
// if you reached it now, print out "I waited in floor <the current floor>"
|
|
|
|
if(CurrentFloor == TargetFloor)
|
|
{
|
|
printf("I waited in floor %d.\n", CurrentFloor);
|
|
|
|
// TODO: when you not reached the pending floor yet,
|
|
// set it to the target floor
|
|
|
|
// TODO: set isDone and reachedPendingFloor appropriately
|
|
isDone = true;
|
|
}
|
|
|
|
}
|
|
}
|