vertc

28-11

Nov 28th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. using namespace std;
  5.  
  6. float F(float x) {
  7.     return sin(x);
  8. }
  9.  
  10. int main () {
  11.     long double p, q, dl, s, pole;
  12.     int n, i;
  13.     cout<<"Podaj liczbe rzeczywista p: "<<endl;
  14.     cin>>p;
  15.     cout<<"Podaj liczbe rzeczywista q: "<<endl;
  16.     cin>>q;
  17.     cout<<"Podaj liczbe prostokatow (liczba naturalna) n: "<<endl;
  18.     cin>>n;
  19.     dl = (q-p) / n;
  20.     s = 0;
  21.     while(i<n) {
  22.         s = s + fabs(F(p+dl*i + (dl/2)));
  23.         i++;
  24.     }
  25.     pole = dl*s;
  26.     cout<<"Pole wynosi: "<<pole<<endl;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment