SWEA 1221 (S/W 문제해결 기본) 5일차 - GNS

1 개요[ | ]

SWEA 1221 (S/W 문제해결 기본) 5일차 - GNS
SW Expert 아카데미
# 문제 풀이

틀:SWEA 난이도 3-7

2 C++[ | ]

3 Java[ | ]

import java.util.*;
public class Solution {
	static Scanner sc  = new Scanner(System.in);
	static StringBuilder sb = new StringBuilder();
	public static void main(String[] args) {
		String[] numStrs={"ZRO","ONE","TWO","THR","FOR","FIV","SIX","SVN","EGT","NIN"};
		int T = sc.nextInt();
		for(int tc=1; tc<=T; tc++) {
			sc.next();
			sc.next();
			sc.nextLine();
			int[] counts = new int[10];
			String str = sc.nextLine().trim();
			for(int i=0; i<10; i++) {
				int len = str.length();
				str = str.replace(numStrs[i],"");
				counts[i] = (len-str.length())/3;
			}
			sb.append(String.format("#%d\n", tc));
			for(int i=0; i<10; i++) {
				for(int j=0; j<counts[i]; j++) sb.append(numStrs[i]+" "); 
			}
			sb.append("\n");
		}
		System.out.println( sb );
		sc.close();
	}
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}