#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
int main(){
double a[100]={0};
double x;
cin>>x;
a[0]=x;
int i=1;
while((a[i]-a[i-1])<0.00001){
a[i]=0.5*(a[i-1]+x/a[i-1]);
i++;
}
printf("%.3lf",a[i-1]);
}
来源:CSDN
作者:徐文小涛涛
链接:https://blog.csdn.net/qq_41440031/article/details/104356971