daily pastebin goal
26%
SHARE
TWEET

Untitled

a guest Nov 9th, 2018 112 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
  1. program aaa;
  2.  
  3.  
  4. {$mode objfpc}{$H+}
  5. uses Classes, SysUtils,math;
  6.  
  7.  
  8. const k=2000;
  9. var a,b,h,s1,s2,s:real;
  10.  i,n,ntest:integer;
  11.  y:array[1..k+1] of real;
  12.  
  13. function f(x:real):real;
  14. begin
  15.  result:=power(3*x*x+5*x-1,1/3);
  16. end;
  17. begin
  18.  
  19.  writeln('a = ');
  20.  readln(a);
  21.  writeln('b = ');
  22.  readln(b);
  23.  ntest:=2;
  24.  while ntest>0 do
  25.  begin
  26.   Writeln('Enter nmber of integerals, less 2000');
  27.   writeln('n = ');
  28.   readln(n);
  29.   ntest:=n mod 2;
  30.  end;
  31.  h:=(b-a)/n;
  32.  y[1]:=f(a);
  33.  y[n+1]:=f(b);
  34.  for i:=2 to n do
  35.  begin
  36.   y[i]:=f(a+h*(i-1));
  37.  end;
  38.  s1:=0;
  39.  s2:=0;
  40.  for i:=2 to n do
  41.  begin
  42.   if (i mod 2)=0 then
  43.    s2:=s2+y[i]
  44.   else
  45.    s1:=s1+y[i];
  46.   end;
  47.  s:=(y[1]+y[n+1]+s1*2+s2*4)*h/3;
  48.  writeln('Integral = ',s);
  49.  readln;
  50. end.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top