题目内容

输入50个数,输出其中的最小的数。Scanner sc=new Scanner(System.in); System.out.println("请输入第1个数:");double num =____;double min =____;for(int i=2 ; ____; ____){ System.out.println("请输入第%d个数", i); num = Double.parseDouble(sc.nextLine()); if(____) { min = num; }}System.out.println(最小值为 " + min);

查看答案
更多问题

输入20个整数,分别求出所有正数之和、所有负数之和、零的个数 Scanner sc=new Scanner(System.in); int positiveSum = 0; int negativeSum = 0; int zeroCount = 0; for(int i=1; ____;i++) { System.out.println("请输入整数"); int num = Integer.parseInt(sc.nextLine()); if ( ____) positiveSum += num; else if ( ____) negativeSum += num; else ____;}System.out.println("正数和" + positiveSum + ",负数和" + negativeSum + ",零的个数" + zeroCount);

判断一个正整数是否为质数Scanner sc=new Scanner(System.in); boolean isPrime = true; System.out.println("请输入一个大于等于2的正整数:"); int num = Integer.parseInt(sc.nextLine()); for ( ____; i < num; i++) { if (num % i == 0) { isPrime = ____; break; } } if (isPrime) System.out.println(num + "是质数!"); else System.out.println(num + "不是质数!");

输出以下图形(第一行前没有空格)**************** ***** **** for(int i=1; ____;i++) { for(int j=1; ____;j++) { System.out.print(" "); } for(int j=1; ____; ____) { System.out.print("*"); } ____; }

打印下面平等四边形(第一行前4个空格,第二行前2个空格,最后一行没有空格)******* ************** for (int i = 1; ____; ____) { for (int j = 1; ____; j++) { System.out.print(" "); } for (int j = 1; ____; j++) { System.out.print("*"); } System.out.println(); }

答案查题题库