求指导,谢谢package com.zyn;
import java.util.Scanner;
public class H4 {
//float x1,x2;
Scanner input = new Scanner(System.in);
float a=input.nextFloat();
float x1=a;
float x2 =((float)(0.5*(x1+a/x1)));
{
while(x1-x2>=0.00001)
{
x1 = x2;
x2 =((float) (0.5*(x1+a/x1)));
}
System.out.printf("%.3f",x1);
}
}
添加回答
举报
0/150
提交
取消