function d = i4vec_distances ( k, locate )

%*****************************************************************************80
%
%% I4VEC_DISTANCES computes a pairwise distance table.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    04 January 2018
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer K, the number of objects.
%
%    integer LOCATE(K), the obect locations.
%
%  Output:
%
%    integer D(K*(K-1)/2), the pairwise distances.
%
  d = zeros ( k * ( k - 1 ) / 2 );

  l = 0;
  for i = 1 : k
    for j = i + 1 : k
      l = l + 1;
      d(l) = abs ( locate(i) - locate(j) );
    end
  end

  return
end
