Language_Coder 547 : 반복제어문2 - 자가진단7

boom.jun.cho·2022년 3월 15일
0

Language_Coder_JUNGOL

목록 보기
87/197

문제

아래와 같이 출력되는 프로그램을 작성하시오.

출력

2 3 4 5 6
3 4 5 6 7
4 5 6 7 8
5 6 7 8 9
6 7 8 9 10

코드

package com.jungol.algorithm087;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	Scanner scanner = new Scanner(System.in);
    	int a = 2;
    	int b = 2;
    	int count = 0;
    	
    	for(int i = 0; i < 5; i++) {
    		for(int j = b + count; j < 7 + count; j++) { 
    			System.out.print(j + " ");    	
    		}
    		count++;
    		System.out.println();
    	}
    	
    	scanner.close();
    }
}	
profile
하루하루 최선을

0개의 댓글