Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- pierwiastek_kwadratowy(float x, float dokladnosc)
- {
- float b = 1;
- while(abs(b-((b+(x/b))/2)) > dokladnosc)
- {
- b = ((b+(x/b))/2);
- }
- cout<<endl;
- cout<<"Pierwiastek z "<<x<<"z dokladnoscia "<<dokladnosc<<" wynosi: "<<b;
- }
- int main()
- {
- float x;
- float dokladnosc;
- cout <<"Podaj liczbe do spierwiastkowania: ";
- cin>>x;
- cout<<endl;
- cout <<"Podaj dokladnosc: ";
- cin>>dokladnosc;
- pierwiastek_kwadratowy(x, dokladnosc);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement