세로읽기 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; public class Main { public static void main(String[] args) throws IOException { // scanner 보다 BufferedReader 가 더 빠름 BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int max = 0; String answer=""; char[][] charList = new char[5][15]; for(int i =0;i<charList.length;i++) { String str = br.readLine(); if(max<str.length()) { max = str.length(); } for(int j=0;j<charList[i].length;j++) { if(j==str.length()){ break; } charList[i][j]=str.charAt(j); } } for(int i=0;i<max;i++) { for(int j=0;j<5;j++) { if(charList[j][i]=='\u0000') { continue; } else { answer+=charList[j][i]; } } } System.out.println(answer); } } 파일 정리 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); HashMap<String,Integer> map = new HashMap<>(); int n; while(true){ String str = br.readLine(); if(!str.contains(".")){ continue; } int dot = str.indexOf('.'); str = str.substring(dot+1); map.put(str,map.getOrDefault(str,0)+1); if(!br.ready()){ break; } } List<String> keyList = new ArrayList<>(map.keySet()); Collections.sort(keyList); for(int i=0;i<keyList.size();i++){ System.out.println(keyList.get(i)+" "+map.get(keyList.get(i))); } } } 단어 뒤집기 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String str = br.readLine(); int index = 0; StringBuilder sb = new StringBuilder(); StringBuilder sbReverse = new StringBuilder(); boolean flag = false; for(int i =0 ;i<str.length();i++){ if(str.charAt(i)=='<'){ flag = true; } // reverse if(flag){ sb.append(str.charAt(i)); } else { if(str.charAt(i)==' '){ sbReverse.reverse(); sbReverse.append(str.charAt(i)); sb.append(sbReverse); sbReverse.setLength(0); } else if(i<str.length()-1 && str.charAt(i+1)=='<') { sbReverse.append(str.charAt(i)); sbReverse.reverse(); sb.append(sbReverse); sbReverse.setLength(0); } else if (i==str.length()-1){ sbReverse.append(str.charAt(i)); sbReverse.reverse(); sb.append(sbReverse); sbReverse.setLength(0); } else { sbReverse.append(str.charAt(i)); } } if(str.charAt(i)=='>'){ flag = false; } } System.out.println(sb.toString()); } }