Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- double staticF(double x){
- return pow(x,2) - x -3;
- }
- double countS(double p, double dl, int n){
- double w = 0;
- for(int i=0; i<n; i++){
- w = w + abs(staticF(p+i*dl+dl/2));
- cout<<"sF"<<staticF(p+i*dl+dl/2)<<endl;
- }
- double s;
- s = w * dl;
- return s;
- }
- int main()
- {
- double p,q;
- int n;
- cout << "Podaj p" << endl;
- cin>>p;
- cout<<endl<<"Podaj q"<< endl;
- cin>>q;
- cout<<endl<<"Podaj n, odpowiadajce za liczbe prostokatow"<<endl;
- cin>>n;
- double dl = (q-p)/n;
- // cout<<dl<<endl;
- cout<<"W Y N I K" <<endl;
- cout<<countS(p, dl, n);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement