View Code of Problem 74

#include "stdio.h"
#include "math.h"
#include "string.h"

void main()
{
	double x2=1.0,x1;	
	double a;
	scanf("%lf",&a);
	for(;x2-x1>=1.0e-5||x1-x2>=1.0e-5;)		//10的-5次方,必须俩值判断
	{
		x1=x2;							//x1,x2初始值1.0,,
		x2=(x1+a/x1)/2.0;
	}
	printf("%.3lf",x2);
}



Double click to view unformatted code.


Back to problem 74