System.out.println("随机生成的数组中的元素为:");
for (int i = 0; i < arr.length; i++) {
System.out.print(arr[i]+" ");
}
System.out.println();
System.out.println("请输入2-5之间的一个数字:");
Scanner sc = new Scanner(System.in);
int num=sc.nextInt();
System.out.println("符条件的元素为:");
for (int i = 0; i < arr.length; i++) {
if (arr[i]%num==0){
System.out.print(arr[i]+" ");
}
}
} |
|