https://www.acmicpc.net/problem/10798
<요약>
A A B C D D
a f z z
0 9 1 2 1
a 8 E W g 6
P 5 h 3 k x
이 주어졌을 때 세로로 읽으라는 것
출력 결과 : Aa0aPAf985Bz1EhCz2W3D1gkD6x
일단 이 문제의 예제부터가 이차원 배열 쓰라고 알려준다. 그래서 입력은 배열로 받고 출력은 이차원 배열 이용해서 출력하면 됨
int max = *max_element(len, len + 5);
#include <iostream>
#include <algorithm>
using namespace std;
int main(void) {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
string str[5];
int len[5] = { 0 };
for (int i = 0; i < 5; i++) {
cin >> str[i];
len[i] = str[i].size();
}
int max = *max_element(len, len + 5);
for (int i = 0; i < max; i++) {
for (int j = 0; j < 5; j++) {
if (i >= str[j].size()) continue;
cout << str[j][i];
}
}
return 0;
}