Notice
Recent Posts
Recent Comments
Link
«   2024/09   »
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
Tags
more
Archives
Today
Total
관리 메뉴

Hennie

[백준] 2742번 : 기찍 N (JAVA) 본문

BaekJoon/03. for문

[백준] 2742번 : 기찍 N (JAVA)

헨니 2021. 4. 14. 23:42

 

QUESTION

www.acmicpc.net/problem/2742

 

2742번: 기찍 N

자연수 N이 주어졌을 때, N부터 1까지 한 줄에 하나씩 출력하는 프로그램을 작성하시오.

www.acmicpc.net

 

ANSWER

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int n = Integer.parseInt(br.readLine());
		
		for(int i=n; i>=1; i--) {
			sb.append(i).append("\n");
		}
		br.close();
		System.out.println(sb);
	}
}

 

RESULT

 

MEMO

2021.04.14 - [BaekJoon/03. for문] - [백준] 2741번 : N 찍기 (JAVA)

 

[백준] 2741번 : N 찍기 (JAVA)

QUESTION www.acmicpc.net/problem/2741 2741번: N 찍기 자연수 N이 주어졌을 때, 1부터 N까지 한 줄에 하나씩 출력하는 프로그램을 작성하시오. www.acmicpc.net ANSWER import java.io.BufferedReader; import..

hennie-dev.tistory.com

똑같은 방식!

'BaekJoon > 03. for문' 카테고리의 다른 글

[백준] 11022번 : A+B - 8 (JAVA)  (0) 2021.04.15
[백준] 11021번 : A+B - 7 (JAVA)  (0) 2021.04.14
[백준] 2741번 : N 찍기 (JAVA)  (0) 2021.04.14
[백준] 15552번 : 빠른 A+B (JAVA)  (0) 2021.04.14
[백준] 8393번 : 합 (JAVA)  (0) 2021.04.13