编写JAVA 程序 输出100~200以内的所有偶数,每10个数一行

来源:百度知道 编辑:UC知道 时间:2024/05/30 10:11:58

/*
* 编写JAVA 程序 输出100~200以内的所有偶数,
* 每10个数一行
*/
public class test{
static void prtOuShu(){
for(int i=100, n=0; i<=200; i++){
if((i&1) == 0){
System.out.print(i + " ");
n++;
}
if(n == 10){
System.out.println();
n = 0;
}
}
}
public static void main(String[] args){
prtOuShu();
}
}

public class Test {

public static void main(String args[]) {
int k=0;
for(int i=100;i<=200;i++)
{
if (i % 2==0)
{
System.out.print(i+" ");
k++;
}

if(k % 10 ==0)
System.out.println();

}
}
}

import java.util.*;

class Test {
public static void main(String[] args) {
Random rand = new Random();
int[] a = new int[200];
int co