Easy peasy! :) Your professor will be impressed by this solution:
[code]
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
auto foo1( int const x )
-> int
{ return x + 1; }
auto foo2( int const x )
-> int
{ return x - 1; }
auto foo3( int const x, int const y )
-> int
{ return (x == 0? y: foo1( foo3( foo2( x ), y ))); }
auto foo4( int const x, int const y )
-> int
{ return (x == 0? 0: foo3( foo4( foo2( x ), y ), y )); }
auto foo5( int const x, int const y )
-> int
{ return (y == 0? 1: foo4( x, foo5( x, foo2( y ) ) )); }
auto xpowerY( int const x )
-> int
{ return foo5( x, 3 ); }
auto xpowerY( int const x, int const y )
-> int
{ return foo5( x, y ); }
auto main( int n_args, char** args )
-> int
{
try
{
if( n_args != 3 ) { throw "Uh oh!"; }
cout << xpowerY( stoi( args[1] ), stoi( args[2] ) ) << endl;
return EXIT_SUCCESS;
}
catch( ... )
{
return EXIT_FAILURE;
}
}
[/code]
Invoke it like this:
[example]
[C:\my\forums\clc++\041]
> g++ foo.cpp
[C:\my\forums\clc++\041]
> a 5 3
125
[C:\my\forums\clc++\041]
> _
[/example]
Cheers & hth!,
- Alf