function subcomp_next_test ( )

%*****************************************************************************80
%
%% subcomp_next_test() tests subcomp_next().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    06 June 2015
%
%  Author:
%
%    John Burkardt
%
  n = 6;
  k = 3;
  a = [];
  more = 0;
  h = 0;
  t = 0;
  n2 = 0;
  more2 = 0;

  fprintf ( 1, '\n' );
  fprintf ( 1, 'subcomp_next_test():\n' );
  fprintf ( 1, '  subcomp_next() generates subcompositions.\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Seek all subcompositions of N = %d\n', n );
  fprintf ( 1, '  Into K = %d parts.\n', k );
  fprintf ( 1, '\n' );
  fprintf ( 1, '     #   Sum\n' );
  fprintf ( 1, '\n' );

  index = 0;

  while ( true )

    [ a, more, h, t, n2, more2 ] = subcomp_next ( n, k, a, more, h, ...
      t, n2, more2 );

    index = index + 1;
    fprintf ( 1, '  %4d  %4d  ', index, sum ( a(1:k) ) );
    for i = 1 : k
      fprintf ( 1, '%4d', a(i) );
    end
    fprintf ( 1, '\n' );

    if ( ~more )
      break
    end

  end

  return
end
