Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- double F(double x)
- {
- return 1/x;
- }
- double oblicz(double p, double q, int n)
- {
- double dl=(q-p)/n, s=0;
- for(int i=0;i<n;i++)
- {
- s+=abs(F(p+dl*i+dl/2));
- }
- return dl*s;
- }
- int main()
- {
- int n;
- int stopien;
- double p,q;
- cout<< "Podaj na ile fragmentow chcesz podzielic obliczane pole"<<endl;
- cin>>n;
- cout<<"Podaj p:"<<endl;
- cin>>p;
- cout<<"Podaj q:"<<endl;
- cin>>q;
- cout<<oblicz(p, q, n);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement