www.wfdy.net > JAVA初学求帮助,流程控制与数组方面,输入的一个数...

JAVA初学求帮助,流程控制与数组方面,输入的一个数...

public static void main(String[] args) { int[] gradeArr = new int[5]; Scanner input = new Scanner(System.in); for (int i = 0; i < 5; i++) { System.out.println("请输入第"+(i+1)+"学生成绩!"); int grade = input.nextInt(); while (...

public class Util{ public static void main(String[] args){ java.util.Scanner sc = new java.util.Scanner(System.in); String[] arr = new String[5]; for(int i = 0; i < arr.length; i++){ arr[i] = sc.next(); } //这里使用util.Arrays...

完整的代码如下: public class Demo01 {public static void main(String[] args) {Scanner sc = new Scanner(System.in);int[] a = new int[10];int i = 0;// 输入10个整数while (true) {a[i] = sc.nextInt();i++;if (i == 10) {break;}}// 冒...

Scanner input = new Scanner(System.in);System.out.print("输入您要找的数:");int number = input.nextInt();int numbers = 0;int [] array = {2,4,5,5,8,9};for(int i = 0 ; i < array.length ; i++){if(number == array[i]){numbers = i+1...

import java.util.ArrayList; import java.util.List; class Test { public static void main(String[] args) { int count = 0; int s = 0; List list = new ArrayList(); int a[] = { 1, 14, 85, 36, 78, 74, 11, 3, 9, 17 }; for (int i = 0; ...

你好,这是答案 import java.util.HashSet;import java.util.Scanner;import java.util.Set;/** * @author liuxe * @since JDK 1.7.0_79 */public class NumberTest { public static void main(String[] args) { Scanner scanner = new Scanner(...

import java.util.Arrays;import java.util.Scanner;public class ScannerTest { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] intArr = new int[10]; for(int i=0;i

你这个肯定错啊,如果第一个不是你输入的数字,马上执行else就跳出循环了,后面的就不会判断了

import java.util.Scanner;public class Main2 { public static void main(String[] args) { int[] a = new int[5]; int sum=0; Scanner scanner = new Scanner(System.in); for (int i = 0; i < a.length; i++) { a[i] = scanner.nextInt(); su...

这个吧,我到现在还没有弄请。

网站地图

All rights reserved Powered by www.wfdy.net

copyright ©right 2010-2021。
www.wfdy.net内容来自网络,如有侵犯请联系客服。zhit325@qq.com