본문 바로가기
프로그래밍/Java

[자바] 구구단 출력(for문 활용, 2단부터 9단까지)

by 청량리 물냉면 2019. 7. 12.
반응형

 

문제

구구단 출력

 

 

실행화면

 

코드
public class gugudan {
	public static void main(String[] args) {
		for(int i=2; i<10; i++) {
			System.out.printf("======"+i+"단======\n"); //i = 단 변수
			for(int j=1; j<10; j++) {  //j = 곱하는 수
				System.out.println(i+"*"+j+"="+i*j);
			}
			System.out.printf("\n");  //구구단 한 단 출력 시마다 한 줄 씩 띄우기
		}
	}
}


 

 

반응형