求指导,谢谢
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); } }
guozhchun
相关分类