Advertisement
555oya

дз 2 часть 4 юнит

Nov 9th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.62 KB | None | 0 0
  1. Unit INTG;
  2.    Interface
  3.       procedure INTG1(n: real; key: integer);
  4.    Implementation
  5.      procedure INTG1;
  6.      function f(x: real): real;
  7. begin
  8.    if key = 1 then result := x + cos(x);
  9.    if key = 2 then result := (sin(x + 1) / cos(x + 1)) / (x + 1);
  10. end;
  11. var a, b, s, delta: real;
  12. begin
  13.   s := 0;
  14.   if key = 1 then begin  
  15.     a := -1; b := 4;
  16.   end;
  17.   if key = 2 then begin
  18.     a := -1.5; b := 0;
  19.   end;
  20.   delta := (b - a) / n;
  21.   s:=(f(a)+f(b))/2;
  22.   while a<b do begin
  23.     a := a + delta;
  24.     s := s + f(a);  
  25.   end;
  26.   s := s * delta;
  27.   writeln('S = ', abs(s));
  28.   end;
  29. End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement