function ksub_next4_test

%*****************************************************************************80
%
%% KSUB_NEXT4_TEST tests KSUB_NEXT4.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    12 May 2018
%
%  Author:
%
%    John Burkardt
%
  k = 3;
  n = 5;
  fprintf ( 1, '\n' );
  fprintf ( 1, 'KSUB_NEXT4_TEST\n' );
  fprintf ( 1, '  KSUB_NEXT4 generates K subsets of an N set.\n' );
  fprintf ( 1, '  N = %d\n', n );
  fprintf ( 1, '  K = %d\n', k );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'Rank    Subset\n' );
  fprintf ( 1, '\n' );

  a = [];
  done = true;
  rank = 0;
 
  while ( true )
 
    [ a, done ] = ksub_next4 ( n, k, a, done );
 
    if ( done )
      break
    end

    rank = rank + 1;
    fprintf ( 1, '  %2d  ', rank );
    for i = 1 : k
      fprintf ( 1, '  %2d', a(i) );
    end
    fprintf ( 1, '\n' );

  end

  return
end
