※ 글쓴이는 취미로 코딩을 익혀보는 사람이라 정확하지 않은 내용을 담고 있을 수 있다 ※

 

이번에 볼 문제는 백준 26495번 문제인 Big Number이다.
문제는 아래 링크를 확인하자.

https://www.acmicpc.net/problem/26495 

 

26495번: Big Number

One of the professors at PLU has had a lot of trouble reading student programs. He just cannot read that small print. Your job is to write a program that will read a positive integer and rewrite the number in large block format. The block format for each d

www.acmicpc.net

주어지는 각 수를 각 자리마다 본문에 주어진 모양대로 크게 출력하는 문제이다.

 

예제의 숫자 '6'의 출력에서 볼 수 있듯이, 불필요하게 뒤에 붙은 공백을 출력하면 안 됨에 유의하자.

 

아래는 제출한 소스코드이다.

#include <iostream>
#include <string>
using namespace std;

string num[5] = {
	"0000    1 2222 3333 4  4 5555 6666 7777 8888 9999 ",
	"0  0    1    2    3 4  4 5    6       7 8  8 9  9 ",
	"0  0    1 2222 3333 4444 5555 6666    7 8888 9999 ",
	"0  0    1 2       3    4    5 6  6    7 8  8    9 ",
	"0000    1 2222 3333    4 5555 6666    7 8888    9 "
};

string s;
string ans[5];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> s;
	int slen = s.length();
	for (int i = 0; i < slen; i++) {
		int n = s[i] - '0';
		for (int r = 0; r < 5; r++) {
			if (num[r][n * 5 + 3] == ' ') cout << num[r][n * 5] << '\n';
			else cout << num[r].substr(n * 5, 4) << '\n';
		}
		cout << '\n';
	}
}
728x90

'BOJ' 카테고리의 다른 글

[BOJ 26531 // C++] Simple Sum  (0) 2022.12.19
[BOJ 2321 // Fortran] Crowing  (0) 2022.12.19
[BOJ 26545 // C++] Mathematics  (0) 2022.12.19
[BOJ 26546 // C++] Reverse  (0) 2022.12.19
[BOJ 6887 // C++] Squares  (0) 2022.12.19

+ Recent posts