Quoto il primo messaggio di IBM aggiungendo che il Politecnico fa male...
In C....
codice:
#include <stdio.h>
#include <stdlib.h>
void recursive( unsigned * const vect, const unsigned size, const unsigned pos );
int main()
{
const unsigned size = 3;
unsigned *v = (unsigned *) malloc( size * sizeof(unsigned) );
recursive( v, size, 0 );
free( v );
getc( stdin );
return 0;
}
void recursive( unsigned * const vect, const unsigned size, const unsigned pos )
{
int i;
if( pos == size )
{
for( i = 0; i != size; ++i )
printf( "%u", vect[ i ] );
putchar( '\n' );
return;
}
vect[ pos ] = 0;
recursive( vect, size, pos+1 );
vect[ pos ] = 1;
recursive( vect, size, pos+1 );
}