未分类题
下面程序段的输出结果是______。 public class Test{ public static void main(String args[ ]){ int x,y; x=(int)Math.sqrt(5/2)+(int)Math.random( )*5/2; y=(int)Math.sqrt(3/2)+(int)Math.random( )*3/2; if(x>y) System.out.println('x>y'); else if(x==y) System.out.println('x=y'); else System.out.println('x<y'); } }
A.x>y
B.x=y
C.x<y
D.编译错误
A.sqrt(5/2)+(int)Math.random(
B.sqrt(3/2)+(int)Math.random(
C.out.println('x>y');
D.out.println('x=y');
E.out.println('x<y');
F.x>y
B.x=y
C.x<y
【参考答案】
A
解析: 本程序中两个赋值语句右边的表达式分别求两个标准函数的值,再进行整除,判断 x和y的大小。Math.s......
(↓↓↓ 点击下方‘点击查看答案’看完整答案 ↓↓↓)