티스토리 뷰
반응형
백준 2941번 크로아티아 알파벳
https://www.acmicpc.net/problem/2941
2941번: 크로아티아 알파벳
예전에는 운영체제에서 크로아티아 알파벳을 입력할 수가 없었다. 따라서, 다음과 같이 크로아티아 알파벳을 변경해서 입력했다. 크로아티아 알파벳 변경 č c= ć c- dž dz= đ d- lj lj nj nj š s= ž z=
www.acmicpc.net




정답 코드
#include<iostream>
#include<string>
using namespace std;
string str;
string map[8] = { "c=","c-","dz=",
"d-","lj","nj","s=","z="
};
int find(int k);
int main() {
cin >> str;
int cnt = 0;
int len2 = str.length();
for (int x = 0; x < 8; x++) {
int len = find(x);
cnt += len;
}
cout << len2-cnt;
}
int find(int k) {
int a = 0, b = 0, cnt = 0;
while (1) {
int res = str.find(map[k], b);
if (res == -1)
break;
cnt++;
b = res + 1;
}
return cnt;
}
문제 풀이
string의 find함수를 이용해서 풀었습니다.
반응형
'Algorithm > BOJ' 카테고리의 다른 글
백준 3003번 C++ (0) | 2023.08.15 |
---|---|
백준 2960번 C++ (0) | 2023.08.15 |
백준 2920번 C++ (0) | 2023.08.15 |
백준 2908번 C++ (0) | 2023.08.14 |
백준 2903번 C++ (0) | 2023.08.14 |
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 카운팅 정렬
- java
- html
- DFS
- 스프링 부트 crud 게시판 구현
- C++
- Do it!
- js
- 자바스크립트
- HTML5
- 스택
- 우선순위 큐
- 자료구조
- 알고리즘
- c++ string
- 투 포인터
- 백준 풀이
- CSS
- 유니온 파인드
- 세그먼트 트리
- 백준
- BFS
- 에라토스테네스의 체
- DP
- 알고리즘 공부
- C++ Stack
- 이분 매칭
- 유클리드 호제법
- 자바
- 반복문
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함