function result = p00_monte_carlo ( problem, n )

%*****************************************************************************80
%
%% p00_monte_carlo() applies the Monte Carlo rule to integrate a function.
%
%  Discussion:
%
%    The function f(x,y) is to be integrated over a triangle T.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    09 April 2007
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer PROBLEM, the problem index.
%
%    integer N, the number of sample points.
%
%  Output:
%
%    real RESULT, the approximate integral.
%
  t = p00_vertices ( problem );

  p = triangle_sample ( t, n );

  f = p00_fun ( problem, n, p );

  area = triangle_area ( t );

  result = area * sum ( f(1:n) ) / n;

  return
end
