그냥 주어진 조건대로 배열을 세로로 접근해서 출력하면 된다.
이때, 쓰레기값이나 '\n'이 저장되어있으면 PASS하면 된다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #include <stdio.h> #include <string.h> int main() { int T; scanf("%d\n", &T); for (int test_case = 1; test_case <= T; test_case++) { char input[5][20] = { {0,}, }; int len = 0; for (int i = 0; i < 5; i++) { scanf("%s", input[i]); int t = strlen(input[i]); if (t > len) len = t; } printf("#%d ", test_case); for (int i = 0; i < len; i++) { for (int j = 0; j < 5; j++) { if(input[j][i]!=0 && input[j][i]!='\n') printf("%c", input[j][i]); } } printf("\n"); } return 0; } | cs |