Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- float f(float x)
- {
- return x*x-4;
- }
- int main()
- {
- //metoda trapezu
- int n;
- float h,p,w,a,b;
- cin>>a;
- cin>>b;
- cin>>n;
- w=(b-a)/n;
- h=0;
- for(int i=1;i<=n;i++)
- {
- h=h+f(a+i*w);
- }
- p=(w/2)*(f(a)+f(b)+2*h);
- cout<<p;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement