Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <iomanip>
- using namespace std;
- int main () {
- long double p, E;
- int L;
- cout<<"Podaj liczbe podpierwiastkowa (p):"<<endl;
- cin>>p;
- cout<<"Podaj dokladnosc obliczen (E): "<<endl;
- cin>>E;
- cout<<"Podaj liczbe literacji (L): "<<endl;
- cin>>L;
- long double a=p;
- int i=0;
- while(fabs(a - (p/a)>E) && i<L) {
- a = (a+(p/a)) / 2;
- i++;
- cout<<a<<"\t";
- }
- cout<<endl<<"Wartosc wynosi: "<<setprecision(15)<<a;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment