Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. double x, x_p, x_k, x_i, s;
  6. int n, i;
  7. double f (x){
  8.     return x^2-x+10;
  9. }
  10. double F1 (x, x_p, x_k, n){
  11.     for(i=0; i<=n; i++){
  12.         s+=f(x_p+(i*(x_k-x_p)/n));
  13.     }
  14.     return s*(x_k-x_p)/n;
  15. }
  16. int main(){
  17. cout<<"podaj x_p: ";
  18. cin>>x_p;
  19. cout<<"\npodaj x_k: ";
  20. cin>>x_k;
  21. cout<<"\npodaj n: ";
  22. cin>>n;
  23. cout<<"\npodaj x: ";
  24. cin>>x;
  25. F1(x, x_p, x_k, n);
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement