Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. double staticF(double x){
  7. return pow(x,2) - x -3;
  8. }
  9.  
  10. double countS(double p, double dl, int n){
  11. double w = 0;
  12. for(int i=0; i<n; i++){
  13. w = w + abs(staticF(p+i*dl+dl/2));
  14. cout<<"sF"<<staticF(p+i*dl+dl/2)<<endl;
  15. }
  16.  
  17. double s;
  18.  
  19. s = w * dl;
  20.  
  21. return s;
  22. }
  23.  
  24. int main()
  25. {
  26. double p,q;
  27. int n;
  28. cout << "Podaj p" << endl;
  29. cin>>p;
  30. cout<<endl<<"Podaj q"<< endl;
  31. cin>>q;
  32. cout<<endl<<"Podaj n, odpowiadajce za liczbe prostokatow"<<endl;
  33. cin>>n;
  34.  
  35. double dl = (q-p)/n;
  36. // cout<<dl<<endl;
  37.  
  38. cout<<"W Y N I K" <<endl;
  39. cout<<countS(p, dl, n);
  40.  
  41.  
  42.  
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement