happy coding

[java] 10798. 세로 읽기 본문

coding study/baekjoon

[java] 10798. 세로 읽기

yeoonii 2023. 8. 12. 14:14
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        char[][] ch = new char[5][15];
        int max = 0;

        for (int i=0 ; i<ch.length ; i++) {
            String str = br.readLine();
            if (max < str.length()) {
                max = str.length();
            }
            for (int j=0 ; j<str.length();j++) {
                ch[i][j] = str.charAt(j);
            }
        }
        StringBuilder sb = new StringBuilder();
        for (int i=0 ; i<max ; i++) {
            for (int j=0 ; j<5 ; j++) {
                if (ch[j][i] == '\0') {
                    continue;
                }
                sb.append(ch[j][i]);
            }
        }
        System.out.println(sb);
    }
}

하다하다 잘 안되서 블로그 짬뽕

Comments