import java.util.Arrays;
import java.util.Scanner;
public class Shuju7 {
public static void main(String[] args) {
int[] nums = new int[10];
int one = 0;
int tow = 0;
int thirt = 0;
int bad = 0;
Scanner scanner = new Scanner(System.in);
System.out.println("请输入10个数:");
for(int i=0;i<nums.length;i++) {
nums[i] = scanner.nextInt();
switch(nums[i]) {
case 1:
one++;
break;
case 2:
tow++;
break;
case 3:
thirt++;
break;
default:
bad++;
break;
}
}
System.out.println("数字1的个数是:" + one);
System.out.println("数字2的个数是:" + tow);
System.out.println("数字3的个数是:" + thirt);
System.out.println("非法数字是:" + bad);
}
}
第七章数组
最新推荐文章于 2021-05-18 00:08:03 发布