Solution Review: Beckett's Problem
Follow the step-by-step instructions to Beckett's problem.
We'll cover the following...
Solution
The program given below shows a prototype of moves( )
and a call to it from main( )
.
Press + to interact
#include <stdio.h>#include <stdbool.h>void moves ( int n, bool flag ) ;int main( ){int n ;n = 3;moves ( n, true ) ;}void moves ( int n, bool flag ){if ( n == 0 )return ;moves ( n - 1, true ) ;if ( flag == true )printf ( "Enter %d\n", n ) ;elseprintf ( "Exit %d\n", n ) ;moves ( n - 1, false ) ;}
...