[백준 / BOJ] 2739번 구구단 (C++, Python)◎ 자료구조와 알고리즘/백준(BOJ) 문제풀이2021. 8. 22. 22:17
반응형
링크 : https://www.acmicpc.net/problem/2739
2739번: 구구단
N을 입력받은 뒤, 구구단 N단을 출력하는 프로그램을 작성하시오. 출력 형식에 맞춰서 출력하면 된다.
www.acmicpc.net
문제

문제 풀이
구구단 출력 문제다!
코드 전문
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> | |
void init() { | |
std::ios_base::sync_with_stdio(false); | |
std::cin.tie(nullptr); | |
std::cout.tie(nullptr); | |
} | |
int main() { | |
init(); | |
int var; | |
std::cin >> var; | |
for (int i = 1; i < 10; ++i) | |
std::cout << var << " * " << i << " = " << var * 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
import sys | |
input = sys.stdin.readline | |
if __name__ == "__main__": | |
val = int(input()) | |
for i in range(1, 10): | |
print(f"{val} * {i} = {val * i}") |
소감
반응형
'◎ 자료구조와 알고리즘 > 백준(BOJ) 문제풀이' 카테고리의 다른 글
[백준 / BOJ] 8393번 합 (C++, Python) (0) | 2021.08.22 |
---|---|
[백준 / BOJ] 10950번 A+B - 3 (C++, Python) (0) | 2021.08.22 |
[백준 / BOJ] 2884번 알람 시계 (C++, Python) (0) | 2021.08.22 |
[백준 / BOJ] 14681번 사분면 고르기 (C++, Python) (0) | 2021.08.22 |
[백준 / BOJ] 2753번 윤년 (C++, Python) (0) | 2021.08.21 |
@Reo :: 코드 아카이브
자기계발 블로그