[BOJ][2739] 구구단
Updated:
1. 문제 링크
https://www.acmicpc.net/problem/2739
2. 사용 알고리즘
구현
3. 풀이
1 ~ 9까지 반복문을 돌며 구구단 출력
4. 소스 코드
4-1. C++
https://github.com/dev-aiden/problem-solving/blob/main/boj/2739.cpp
1
2
3
4
5
6
7
8
9
10
#include <iostream>
using namespace std;
int main(void) {
ios_base::sync_with_stdio(false);
int n; cin >> n;
for (int i = 1; i < 10; ++i) cout << n << " * " << i << " = " << n * i << '\n';
return 0;
}
4-2. JAVA
https://github.com/dev-aiden/problem-solving/blob/main/boj/2739.java
1
2
3
4
5
6
7
8
9
10
11
12
13
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
int n = Integer.parseInt(br.readLine());
for(int i = 1; i < 10; ++i) sb.append(n).append(" * ").append(i).append(" = ").append(n * i).append('\n');
System.out.println(sb);
}
}
Leave a comment