算法第四版 1.1.

1.1.1 结果  a:7 或 7.0 b:1562500.0015625

c:true

public class P1_1_1{
	public static void main(String[] args) {
	double aa = (0+15)/2;
        int a = (0 + 15) / 2;
        double b = Math.pow(2.0, -6) * 100000000.1; //Math.Pow(double x, double y) 求x的y次方
        boolean c = true && false || true && true;
        System.out.println(a+"  "+aa+" "+b);
        if (c) System.out.println(true);
        else System.out.println(false);
        
	}
}

1.1.2a:1.618  b:10.0  c:true d: 33

public class P1_1_2 {
	public static void main(String[] args) {
		double a = (1+2.236)/2;
		double  b = 1+2+3+4.0;
		boolean c= 4.1<=4;
		String d = 1+2+"3";
		System.out.println(a+" "+b+" "+d);
		if(c) StdOut.println(true);
		else StdOut.println(false);
	}
}

1.1.3

 

猜你喜欢

转载自blog.csdn.net/qq_38339863/article/details/79242699