function compnz_next_test ( )

%*****************************************************************************80
%
%% compnz_next_test() tests compnz_next().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    22 May 2015
%
%  Author:
%
%    John Burkardt
%
  n = 6;
  k = 3;
  a = [];
  more = 0;
  h = 0;
  t = 0;

  fprintf ( 1, '\n' );
  fprintf ( 1, 'compnz_next_test():\n' );
  fprintf ( 1, '  compnz_next() generates compositions\n' );
  fprintf ( 1, '  with nonzero parts.\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Seeking all compositions of N = %d\n', n );
  fprintf ( 1, '  using %d nonzero parts.\n', k );
  fprintf ( 1, '\n' );
  
  while ( true )

    [ a, more, h, t ] = compnz_next ( n, k, a, more, h, t );
    
    fprintf ( 1, '  ' );
    for i = 1 : k
      fprintf ( 1, '%2d  ', a(i) );
    end
    fprintf ( 1, '\n' );

    if ( ~more )
      break
    end

  end

  return
end
