#include <iostream>
#include <string>

using namespace std;
int main() {
	string s[5];
	string result="";

	cin >> s[0] >> s[1] >> s[2] >> s[3] >> s[4];
	
	int max = 0;
	for (int i = 0; i < 5; i++)
	{
		if (max < s[i].length())
			max = s[i].length();
	}
	for (int i = 0; i < max; i++)
	{
		for (int j = 0; j < 5; j++)
		{
			try
			{
				result += s[j].substr(i, 1);
			}
			catch (exception e)
			{
				continue;
			}
		}
	}
	cout << result;
}

 

 

 

문제: https://www.acmicpc.net/problem/10798

 

10798번: 세로읽기

총 다섯줄의 입력이 주어진다. 각 줄에는 최소 1개, 최대 15개의 글자들이 빈칸 없이 연속으로 주어진다. 주어지는 글자는 영어 대문자 ‘A’부터 ‘Z’, 영어 소문자 ‘a’부터 ‘z’, 숫자 ‘0’

www.acmicpc.net

'Baekjoon > C++' 카테고리의 다른 글

[백준 1010번] 다리 놓기  (0) 2023.07.24
[백준 1003번] 피보나치 함수  (0) 2023.07.21
[백준 1002번] 터렛  (0) 2023.07.21
[백준 2563번] 색종이  (0) 2023.07.19
[백준 2566번] 최댓값  (0) 2023.05.23

+ Recent posts