![[백준 / BOJ] 2742번 기찍 N (C++, Python)](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FcuogL8%2FbtrJik1m27K%2FM6iNzS5ovnWNDKdanidGhk%2Fimg.png)
[백준 / BOJ] 2742번 기찍 N (C++, Python)◎ 자료구조와 알고리즘/백준(BOJ) 문제풀이2021. 8. 23. 00:28
Table of Contents
반응형
링크 : https://www.acmicpc.net/problem/2742
2742번: 기찍 N
자연수 N이 주어졌을 때, N부터 1까지 한 줄에 하나씩 출력하는 프로그램을 작성하시오.
www.acmicpc.net
문제

문제 풀이
N부터 1까지 출력하면 되는 문제다!
C++ 코드 전문
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
int main() | |
{ | |
std::ios_base::sync_with_stdio(false); | |
int val; | |
std::cin >> val; | |
for (int i = val; i > 0; i--) | |
std::cout << i << "\n"; | |
return 0; | |
} |
Python 코드 전문
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val = int(input()) | |
for i in range(val, 0, -1): # range 함수는 초기값, 종료값, 증가값으로 인수를 받기 때문에. | |
print(i) |
소감
반응형
'◎ 자료구조와 알고리즘 > 백준(BOJ) 문제풀이' 카테고리의 다른 글
[백준 / BOJ] 11022번 A+B - 8 (C++, Python) (0) | 2021.08.23 |
---|---|
[백준 / BOJ] 11021번 A+B - 7 (C++, Python) (0) | 2021.08.23 |
[백준 / BOJ] 2741번 N 찍기 (C++, Python) (0) | 2021.08.23 |
[백준 / BOJ] 15552번 빠른 A+B (C++, Python) (0) | 2021.08.22 |
[백준 / BOJ] 8393번 합 (C++, Python) (0) | 2021.08.22 |
@Reo :: 코드 아카이브
자기계발 블로그