ksszztof

kod do...while

Aug 29th, 2015
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <cmath>
  4.  
  5. using namespace std ;
  6.  
  7.  
  8. int main ()
  9.  
  10. {
  11. double x1, s, checkx,x, eps ;
  12.  
  13. double newton (double x) ;
  14. {
  15.  
  16.  
  17. cout<< "Podaj liczbe, ktora chcesz pierwiastkowac:"<<"" ;
  18. cin>> s ;
  19. cout<< "Podaj wartosc poczatkowa:"<<endl;
  20. cin>> x ;
  21. cout<< "Podaj dokladnosc:"<<"" ;
  22. cin>> eps ;
  23.  
  24. }
  25.  
  26.  
  27. do
  28. {
  29. x1=0,5*(x+(s/x)) ;
  30. checkx=x-x1 ;
  31. x=x1 ;
  32. cout<< x1 <<endl ;
  33. }
  34.  
  35. while (checkx<=eps);
  36.  
  37.  
  38. return x1;
  39.  
  40. cout<< x1 ;
  41.  
  42. return 0 ;
  43. system ("pause");
  44.  
  45.  
  46.  
  47.  
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment