```
백준 25246번 Brexiting and Brentering JAVA 구현해보기
```

이번 글을 통해 배워갈 내용
- 백준 25246번 Brexiting and Brentering 풀이
https://www.acmicpc.net/problem/25246
25246번: Brexiting and Brentering
This is not a problem about Brexit. Or at least not about the social or economic implications of Brexit. Instead, we -- the Grammatical Correctness Policing Committee (GCPC) -- want to focus exclusively on the linguistic challenges posed by this combinatio
www.acmicpc.net
백준 25246번 Brexiting and Brentering는
난이도 브론즈 등급의 문제로서
알파벳으로 이뤄진 문자열이 주어지고
마지막에 나오는 vowel (a, e, i, o, u)의 뒤에 모든 문자를 지우고
"ntry"로 바꿔주면 되는 문제입니다.
30분 정도 위에 링크를 방문하셔서 풀어보시고
안 풀리시는 경우에만 아래 해답을 봐주시면 감사하겠습니다.
입력을 받고
마지막에 나오는 vowel의 위치를 찾아서
그뒤에 문자열을 substring으로 빼주고 "ntry"를 문자열에 더한 다음
출력했습니다.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
// 입력
final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
final String name = br.readLine();
// 출력
System.out.print(findEntering(name));
}
private static String findEntering(String name) {
final String vowels = "aeiou";
String retVal = name;
for (int idx = name.length() - 1; idx >= 0; idx--) {
if (vowels.indexOf(name.toLowerCase().charAt(idx)) >= 0) {
retVal = name.substring(0, idx + 1) + "ntry";
break;
}
}
return retVal;
}
}
// https://codemasterkimc.tistory.com
읽어주셔서 감사합니다
무엇인가 얻어가셨기를 바라며
오늘도 즐거운 코딩 하시길 바랍니다 ~ :)
728x90
'Java > Java 알고리즘' 카테고리의 다른 글
| 백준 19698번 헛간 청약 JAVA 구현해보기 (0) | 2022.08.16 |
|---|---|
| 백준 2744번 대소문자 바꾸기 JAVA 구현해보기 (0) | 2022.08.15 |
| 백준 25372번 6자리 이상 9자리 이하 판별 JAVA 구현해보기 (0) | 2022.08.12 |
| 백준 25314번 코딩은 체육과목 입니다 JAVA 구현해보기 (0) | 2022.07.30 |
| 백준 25278번 Terraforming JAVA 구현해보기 (0) | 2022.07.29 |