function [ l, value ] = i4vec_max_last ( l_length, l )

%*****************************************************************************80
%
%% I4VEC_MAX_LAST moves the maximum entry of an I4VEC to the last position.
%
%  Discussion:
%
%    This routine finds the largest entry in an array and moves
%    it to the end of the array.
%
%    If we ignore this last array entry, then the effect is the same
%    as "deleting" the maximum entry from the array.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    09 January 2018
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Pavel Pevzner,
%    Computational Molecular Biology,
%    MIT Press, 2000,
%    ISBN: 0-262-16197-4,
%    LC: QH506.P47.
%
%  Input:
%
%    integer L_LENGTH, the length of the array.
%
%    integer L(L_LENGTH), the array.
%
%  Output:
%
%    integer L(L_LENGTH),
%    the maximum entry has been shifted to the end.
%
%    integer VALUE, the maximum entry in the input array.
%
  for i = 2 : l_length
    if ( l(i) < l(i-1) )
      t = l(i);
      l(i) = l(i-1);
      l(i-1) = t;
    end
  end
 
  value = l(l_length);

  return
end
