Java/Java 알고리즘

백준 25205번 경로당펑크 2077 JAVA 구현해보기

kimc 2022. 5. 28. 20:53

```

백준 25205번 경로당 펑크 2077 JAVA 구현해보기

```

이번 글을 통해 배워갈 내용

  1. 백준 25205번 풀이

https://www.acmicpc.net/problem/25205

 

25205번: 경로당펑크 2077

시은이는 종합설계 프로젝트로 오픈월드 액션 고스톱 게임 경로당펑크 2077을 개발하고 있다. 대사를 추가하던 중, 사용자 이름에 따라 '을' 또는 '를' 중 하나를 출력해야 함을 깨달았다. 예를 들

www.acmicpc.net

 

백준 25205번 경로당펑크 2077은

난이도 브론즈 등급의 문제로서

 

영문 소문자가 키보드 좌판 한글 문자로 매핑돼 있을 때

 

문자열을 받고 해당 문자열에

마지막 글자에 받침이 있다면 

1 없다면 0을 출력하면 되는 문제입니다.


30분 정도 위에 링크를 방문하셔서 풀어보시고

안 풀리시는 경우에만 아래 해답을 봐주시면 감사하겠습니다.


마지막 글자가 중성이 아니라면 받침이 있는 것입니다.

 

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    public static void main(String[] args) throws IOException {
        final String input01 = br.readLine();
        final String input02 = br.readLine();
        System.out.print(solve(input02));
    }

    private static String solve(String input02) {
        // 마지막 단어에 받침 종성 존재 여부
        return !isJoongSung(input02.charAt(input02.length()-1)) ? "1" : "0";
    }

    // 한글 중성 판별 method
    // ㅏ, ㅐ, ㅑ, ㅒ, ㅓ, ㅔ, ㅕ, ㅖ, ㅗ, ㅘ, ㅙ, ㅚ, ㅛ, ㅜ, ㅝ, ㅞ, ㅟ, ㅠ, ㅡ, ㅢ, ㅣ
    private static boolean isJoongSung(char lastChar) {
        boolean isJoongSung = false;
        switch (lastChar){
            case 'y':
            case 'u':
            case 'i':
            case 'o':
            case 'p':
            case 'h':
            case 'j':
            case 'k':
            case 'l':
            case 'b':
            case 'n':
            case 'm':
                isJoongSung = true;
                break;
            default:
                break;
        }
        return isJoongSung;
    }

}

//codemasterkimc.tistory.com [김씨의 코딩 스토리]

 

읽어주셔서 감사합니다

 

무엇인가 얻어가셨기를 바라며

 

오늘도 즐거운 코딩 하시길 바랍니다 ~ :)

 


 

728x90