※ 글쓴이는 취미로 코딩을 익혀보는 사람이라 정확하지 않은 내용을 담고 있을 수 있다 ※
이번에 볼 문제는 백준 6903번 문제인 Trident이다.
문제는 아래 링크를 확인하자.
https://www.acmicpc.net/problem/6903
6903번: Trident
A trident is a fork with three tines (prongs). A simple picture of a trident can be made from asterisks and spaces: * * * * * * * * * ******* * * * * In this example, each tine is a vertical column of 3 asterisks. Each tine is separated by 2 spaces. The ha
www.acmicpc.net
t개의 행에 세 개의 tine을, 한개의 행에 가로줄을, 마지막으로 h개의 행에 손잡이를 순서대로 출력해 문제를 해결하자.
손잡이 부분을 출력할 때 줄 끝에 추가적인 공백(trailing spaces)을 삽입하면 안됨에 유의하자.
아래는 제출한 소스코드이다.
#include <iostream>
using namespace std;
int T, S, H;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> T >> S >> H;
for (int t = 0; t < T; t++) {
cout << '*';
for (int s = 0; s < S; s++) cout << ' ';
cout << '*';
for (int s = 0; s < S; s++) cout << ' ';
cout << '*' << '\n';
}
for (int i = 0; i < 2 * S + 3; i++) cout << '*';
cout << '\n';
for (int h = 0; h < H; h++) {
for (int s = 0; s <= S; s++) cout << ' ';
cout << '*' << '\n';
}
}
728x90
'BOJ' 카테고리의 다른 글
[BOJ 26731 // C++] Zagubiona litera (0) | 2022.12.23 |
---|---|
[BOJ 11580 // C++] Footprint (0) | 2022.12.23 |
[BOJ 26553 // C++] Work (0) | 2022.12.23 |
[BOJ 26736 // C++] Wynik meczu (0) | 2022.12.23 |
[BOJ 5353 // C++] Open Intervals (0) | 2022.12.23 |