View Code of Problem 74

#include <iostream>
#include <cstdio>
#include <iomanip>
#include <cmath>
using namespace std;
int main(){
    double x,a,t=0,y;
    cin>>a;
    x=a/2.0;
    y=1.0/2.0*(x+a/x*1.0);
    while(abs(x-y)>=0.00001){
        x=y;
        y=1.0/2.0*(x+a/x*1.0);
//        x=a/2.0;
    }
    cout<<fixed<<setprecision(3)<<y<<endl;
    return 0;
}














Double click to view unformatted code.


Back to problem 74