62,614
社区成员
发帖
与我相关
我的任务
分享
class BvP{
static int[] a = { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 };
static int j = 0;
public static int[] BdP(int[] b) {
for (int i = 0; i < a.length; i++) {
for (j = i + 1; j < a.length; j++) {
if (a[j] == 0 && j < a.length-1) {
j = j + 1;
}
if (a[i] == 0) {
i = i + 1;
} else if (a[j] % a[i] == 0) {
a[j] = 0;
}
}
if(a[i]!=0){
System.out.print(a[i] + " ");
}
}
return b;
}
public static void main(String[] args) {
BdP(a);
}
}
class BvP{
static int[] a={2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
static int j=0;
public static int [] BdP(int[] b){
for(int i=0;i <a.length;i++){
for(j=2;j <a[i];j++){
if(a[i]%j==0){
a[i]=0;
}
}
System.out.print(a[i]+" ");
}
return b;
}
public static void main(String[] args){
BdP(a);
}
}