티스토리 뷰

Java

[JAVA] printf 2

berryberries 2023. 3. 3. 00:32
printf()를 이용해서 구구단 출력해보기

구구단 이거로도 가능하다.

 

public class PrintfAndPrintln {
	public static void main(String[] args) {
	System.out.print("   | ");
		
	for(int i = 1; i < 9; i++) {
		System.out.printf("%3d",i);
	}
		
	System.out.println("\n --+--------------------------");
	
	for(int i=1; i<9;i++) {
		System.out.printf("%2d | ",i);
			
		for(int j=1;j<9;j++) 
			System.out.printf("%3d",i*j);
			System.out.println();					
		}
	}	
}

※ printf() 감잡기

 

[출처 ]https://althathatha.tistory.com/12

'Java' 카테고리의 다른 글

[JSP]req.getParameter와 req.setAttribute  (0) 2023.04.24
[오류]Multiple annotations found at this line  (0) 2023.03.19
[JAVA] printf 1  (0) 2023.03.03
[JAVA] 객체지향 프로그래밍 2  (0) 2023.02.27
[JAVA]객체지향 프로그래밍 1  (0) 2023.02.27
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
글 보관함