Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- amazon
- 텐션 업 10기!
- 모르고리즘
- 수학
- Hamming weight
- SSAFY 10기 화이팅
- 우유가 옆으로 넘어지면 아야
- Have a good day :)
- SSAFY 테스트
- 우유가옆으로넘어지면아야
- DP
- HAVE A GOOD DAY
- 우유아야
- I am Korean
- Have a nice day.
- LeetCode #릿코드 #좋은 하루 되세요 #Have a nice day
- 자고 싶다
- 텐션 업 10기 화이팅
- SSAFY 화이팅
- BFS
- DFS
- have a nice day
- 자료구조
- 코로나 싫어요
- SSAFY IM/A
- 아자아자 화이팅
- 네트워크
- Java 환경 설정
- SeongSeobDang
Archives
- Today
- Total
Hope Everyone Is Happy
[실버5] 2941. 크로아티아 알파벳 (Java) 본문
※ 백준 (Baekjoon)/[Java] 문제 풀이 ( Solve the problems)
[실버5] 2941. 크로아티아 알파벳 (Java)
J 크 2023. 8. 27. 11:21728x90
반응형
https://www.acmicpc.net/problem/2941
2941번: 크로아티아 알파벳
예전에는 운영체제에서 크로아티아 알파벳을 입력할 수가 없었다. 따라서, 다음과 같이 크로아티아 알파벳을 변경해서 입력했다. 크로아티아 알파벳 변경 č c= ć c- dž dz= đ d- lj lj nj nj š s= ž z=
www.acmicpc.net
IM, A형 테스트 화이팅입니다~!!
※ 문제를 요약하면 아래와 같습니다.
▶ 크로아티아 알파벳 6개가 아래와 같이 영어로 변형하여 존재
▶ 단어가 입력 되었을 때, 위에 해당되는 알파벳 들은 하나로 카운트하여 단어 내 총 알파벳(영어 포함) 갯수 출력
▶ Input : 첫줄에 최대 100글자의 단어가 알파벳 소문자와 '-', '='로만 이루어짐
▶ Output : 단어 내 알파벳 갯수 출력
◈ Input -1
ljes=njak
◈ Output-1
6
◈ Input -2
ddz=z=
◈ Output-2
3
◈ Input -3
nljj
◈ Output-3
3
◈ Input -4
c=c=
◈ Output-4
2
◎ 코드 작성 전, 아래와 같이 솔루션을 정리하였습니다.
▶ 크로아티아 알파벳들은 임의로 알파벳 'a'로 변경하여 길이를 읽을 때 1로 읽도록 변경
▶ 변경 후 문자열 길이 출력
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
public class Main {
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
BufferedReader bReader = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bWriter = new BufferedWriter(new OutputStreamWriter(System.out));
//StringTokenizer st = new StringTokenizer(bReader.readLine());
String strAlphabets = bReader.readLine();
String[] strCroatia = {"c=", "c-", "dz=", "d-", "lj", "nj", "s=", "z="};
for(int i = 0 ; i < strCroatia.length; i++) {
while(strAlphabets.contains(strCroatia[i])) {
strAlphabets = strAlphabets.replace(strCroatia[i], "a");
}
}
int nCount = strAlphabets.length();
bWriter.write(String.valueOf(nCount));
bWriter.flush();
bWriter.close();
}
}
읽어주셔서 감사합니다!
Good Luck! (피드백 감사합니다!)
'※ 백준 (Baekjoon) > [Java] 문제 풀이 ( Solve the problems)' 카테고리의 다른 글
[브론즈1] 10163. 색종이 (Java) (0) | 2023.08.27 |
---|---|
[실버4] 11399. ATM (Java) (0) | 2023.08.27 |
[실버4] 2567. 색종이 - 2 (Java) (0) | 2023.08.24 |
[실버1] 2527. 직사각형 (Java) (0) | 2023.08.23 |
[실버2] 2477. 참외밭 (Java) (0) | 2023.08.22 |