public class Main {
public static void main(String[] args) {
for (int i = 1; i <= 100; i++) {
System.out.print(i);
if(i < 100){
System.out.print(", ");
}
if(i % 10 == 0){
System.out.println("");
}
}
}
}
1부터 100까지 숫자들을 한눈에 쉽게 보기 위해서 10개씩 끊어서 출력했습니다.
public class Main {
public static void main(String[] args) {
for (int i = 1, count = 0; i <= 100; i++) {
if(i % 2 == 0){
count++;
if(count % 10 == 0){
System.out.print(i);
System.out.println();
}else {
System.out.print(i+ ", ");
}
}
}
}
}
1번과 같이 1부터 100까지 짝수들을 ','로 구분하고 10개씩 끊어 출력했습니다.
public class Main {
public static void main(String[] args) {
for (int j = 2; j <= 9; j++) {
System.out.print("== "+j+ "단 ==\t");
}
System.out.println();
for (int i = 1; i <= 9;i++) {
for (int j = 2; j <= 9; j++) {
System.out.print(j + " * " + i + " = " + (i*j) + "\t");
}
System.out.println();
}
}
}
이번에는 구구단을 가로로 출력 했습니다.