Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <algorithm>
- using namespace std;
- double TrapeznoPravilo (double f(double ), int a, int b, int n) {
- double suma=0;
- for (int i=1; i<n; i++) {
- suma+=f(a+((b-a)/n)*i);
- }
- suma+=(1/2)*(f(a)+f(b));
- return suma*(b-a)/n;
- }
- int main () {
- cout<<"Rezultat funkcije: "<<TrapeznoPravilo( [] (double x) { return x*x*x; },0,10,5);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement