文档详情

java经典编程笔试题.docx

发布:2023-08-26约1.23千字共2页下载文档
文本预览下载声明
题目1:一个球从100米高度自由落下,每次落地后反跳回原高度的一半;在落下,求它在第10次落地时,共经过多少米?第十次反弹多高? 如果把double类型换成int类型定义你认为它共经过多少米 反弹高度又会是多少? public static void main(String[] args) { double h = 100,s = 100; for(int i=1; i10; i++) { s = s + h; h = h / 2; } System.out.println(经过路程: + s); System.out.println(反弹高度: + h / 2); } 题目2:有1、2、3、4个数字,能组成多少个相同且无重复数字的三位数 public static void main(String[] args) { int a = 0; for(int x=1; x5; x++) { for(int y=1; y5; y++) { for(int z=1; z5; z++) { if(x != y y != z x != z) { a ++; System.out.println(x*100 + y*10 + z ); } } } } System.out.println(a); } 题目3:一个整数,它加上100后是一个完全平方数,再加上168又是一个完全平方数,请问该数是多少? public static void main(String[] args) { for (int x = 1; x 100000; x++) { if (Math.sqrt(x + 100) % 1 == 0) { if (Math.sqrt(x + 268) % 1 == 0) { System.out.println(x); } } } } 題目4:下面代码输出结果是什么? package test; public class Test { public static void main(String[] args) { double val = 11.5; System.err.println(Math.round(val)); System.err.println(Math.floor(val)); System.err.println(Math.ceil(val)); } }
显示全部
相似文档