Java/기타 알고리즘

1부터 100까지 짝수를 출력하되 한 줄에 10개씩 출력하라.

은찡안찡 2023. 4. 5. 17:40

문제> 1부터 100까지 짝수를 출력하되 한 줄에 10개씩 출력하라.

 

package com.dream.controls;

public class OverLapEx02 {
	public static void main(String[] args) {
		for(int i=2; i<=100; i+=2) {
			System.out.print("\t"+i);
			if(i % 20 == 0) System.out.println("\n");
		}
	}
}