Advertisement
Guest User

Untitled

a guest
May 20th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. double f(int x)
  6. {
  7. return 3*x + 1;
  8. }
  9.  
  10. double p(int x)
  11. {
  12. return 3;
  13. }
  14.  
  15.  
  16. int main()
  17. {
  18. int n;
  19. double a,b;
  20.  
  21. cout<<"Podaj poczatek przedzialu: ";
  22. cin>>a;
  23. cout<<"Podaj koniec przedzialu: ";
  24. cin>>b;
  25. cout<<"Podaj ilosc iteracji: ";
  26. cin>>n;
  27. double x[n];
  28.  
  29. for(int i = 1; i < n;i++)
  30. {
  31. x[i] = x[i-1] - f(x[i-1])/p(x[i-1]);
  32. }
  33.  
  34.  
  35. cout<<"Miejsce zerowe to ~ "<<x[n]<<endl;
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement