function permutation_print ( p, label )

%*****************************************************************************80
%
%% permutation_print() prints a permutation of (1,...,N).
%
%  Example:
%
%    Input:
%
%      P = 7 2 4 1 5 3 6
%
%    Printed output:
%
%      "This is the permutation:"
%
%      1 2 3 4 5 6 7
%      7 2 4 1 5 3 6
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    14 September 2022
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer P(N), the permutation, in standard index form.
%
%    string LABEL, an optional title.
%
  n = permutation_order ( p );

  inc = 20;

  fprintf ( 1, '\n' );
  fprintf ( 1, '%s\n', label );

  for ilo = 1 : inc : n
    ihi = min ( n, ilo + inc - 1 );

    fprintf ( 1, '\n' );
    fprintf ( 1, '  ' );
      
    for i = ilo : ihi
      fprintf ( 1, '%4d', i )
    end
    fprintf ( 1, '\n' );

    fprintf ( 1, '  ' );
    for i = ilo : ihi
      fprintf ( 1, '%4d', p(i) )
    end
    fprintf ( 1, '\n' );

  end

  return
end
