문제 출처: www.acmicpc.net/problem/2739
2739번: 구구단
N을 입력받은 뒤, 구구단 N단을 출력하는 프로그램을 작성하시오. 출력 형식에 맞춰서 출력하면 된다.
www.acmicpc.net
1. 코드
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> | |
using namespace std; | |
int main(void) | |
{ | |
int n; | |
cin >> n; | |
for(int i = 1; i < 10; i++) | |
cout << n << " * " << i << " = " << n * i << endl; | |
return 0; | |
} |
2. 풀이
int n;
cin >> n;
먼저 n을 입력을 받는다.
for(int i = 1; i < 10; i++)
cout << n << " * " << i << " = " << n * i << endl;
그리고 반복문을 이용하여 예제 출력에서 나오는 것처럼 나오게 만들면 된다.
'컴퓨터 > 백준 알고리즘' 카테고리의 다른 글
백준 알고리즘 8393번: 합 [C++][재귀] (0) | 2020.12.03 |
---|---|
백준 알고리즘 10950번: A+B - 3 [C++] (0) | 2020.12.01 |
백준 알고리즘 2884번: 알람 시계 [C++] (0) | 2020.11.29 |
백준 알고리즘 14681번: 사분면 고르기 [C++] (0) | 2020.11.27 |
백준 알고리즘 9498번: 시험 성적 [C++] (0) | 2020.11.24 |