![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
java入门题目
简单的java入门级题目解析
巴巴卡奥
嘿,从头开始,还来得及!!!
展开
-
猜数字游戏
题目描述:完成猜数字游戏。从键盘输入每次猜的数字,系统提示猜的值比实际值“大了”或“小了”。直到猜中数字。 //题目14:完成猜数字游戏 public static void main14(String[] args) { Scanner scan = new Scanner(System.in); Random random = new Random(); //随机数类,如果给定了一个时间戳,那么给定的数字都是一样的了原创 2021-04-16 20:51:13 · 60 阅读 · 0 评论 -
最大公约数
题目描述:解法一:求两个整数的最大公约数。例如:输入:18 24输出:6 public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.println("请依次输入两个正整数:"); int num1 = scan.nextInt(); int num2 = scan.nextInt(); i原创 2021-04-16 20:45:22 · 48 阅读 · 0 评论 -
打印乘法口诀表
题目描述:打印输出乘法口诀表在这里插入代码片 public static void main(String[] args) { int i = 1; while (i <= 9) { int j = i; while (j <= 9) { System.out.printf("%d*%d=%2d ", i, j, i * j); j++;原创 2021-04-16 20:33:01 · 66 阅读 · 0 评论 -
打印素数(1-100)
题目描述:打印1-100以内所有的素数。(素数:只有1和他本身两个因数) public static void main(String[] args) { int i = 1; while (i <= 100) { int j = 2; int flg = 1; //定义一个标志来记录,1代表质数,0代表合数。 while (j <= (原创 2021-04-16 20:30:14 · 4356 阅读 · 1 评论 -
判断素数(只有1和它本身两个因数)
题目描述:从键盘循环输入,判定一个数字是否是素数(只有1和它本身两个公因数)。输0退出! public static void main(String[] args) { Scanner scan = new Scanner(System.in); while (true) { System.out.println("请输入一个整数(输0退出):"); int num = scan.nextInt();原创 2021-04-16 20:25:34 · 630 阅读 · 0 评论