ALGORITHM/SWEA

[SWEA D3] 4406. 모음이 보이지 않는 사람

lemon-scone 2023. 4. 5. 17:29

https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=3&contestProbId=AWNcD_66pUEDFAV8&categoryId=AWNcD_66pUEDFAV8&categoryType=CODE&problemTitle=&orderBy=PASS_RATE&selectCodeLang=JAVA&select-1=3&pageSize=10&pageIndex=1 

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com

import java.io.*;
import java.util.*;

public class Main {
  public static void main(String[] args) throws Exception {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();

    String[] exception = { "a", "e", "i", "o", "u" };
    // replace(string, string) 만 가능해서 char[] 이 아닌 string[] 으로 배열 초기화

    int TC = Integer.parseInt(br.readLine());
    for (int tc = 1; tc <= TC; tc++) {
      sb.append("#").append(tc).append(" ");

      String input = br.readLine();
      String output = input;

      for (int i = 0; i < exception.length; i++) {
        output = output.replace(exception[i], "");
      }
      sb.append(output).append("\n");
    }
    System.out.println(sb.toString());
  }
}