일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- BOJ
- codeSyntaxHighlight
- 이분탐색
- C++
- js
- 위클리 챌린지
- 1620
- 10162
- 정수 삼각형
- Hasing
- 소수 체크
- 구간 합 구하기 4
- 5525
- 주식 가격
- 4796
- 18111
- 2018 KAKAO BLIND RECRUITMENT
- 숫자 문자열과 영단어
- n^2 배열 자르기
- Git Convention
- mermaid js
- 없는 숫자 더하기
- 깊이 우선 탐색
- colorSyntax
- react
- 브루트포스 알고리즘
- 다이내믹 프로그래밍
- 프로그래머스
- javascript
- 옵셔널 체이닝 연산자
Archives
- Today
- Total
개발하는 kim-hasa
[c++][BOJ][2941] 크로아티아 알파벳 본문
https://www.acmicpc.net/problem/2941
2941번: 크로아티아 알파벳
예전에는 운영체제에서 크로아티아 알파벳을 입력할 수가 없었다. 따라서, 다음과 같이 크로아티아 알파벳을 변경해서 입력했다. 크로아티아 알파벳 변경 č c= ć c- dž dz= đ d- lj lj nj nj š s= ž z=
www.acmicpc.net
표현할 수 없는 크로아티아 알파벳을 변환해서 구하는 문제입니다.
처음부터 index로 위치를 찾고, 하나하나 경우의 수를 찾아가면서 구하는 문제입니다.
#include <iostream>
#include <string>
using namespace std;
int main(){
string str;
cin >> str;
int index = 0;
int count = 0;
int len = str.length();
while(index < len)
{
if(str[index] == 'c')
{
if(str[index+1] == '=')
{
count++;
index += 2;
}
else if(str[index+1] == '-')
{
count++;
index += 2;
}
else
{
count++;
index++;
}
}
else if(str[index] == 'd')
{
if(str[index+1] == '-')
{
count++;
index += 2;
}
else if(str[index+1] == 'z' && str[index+2] == '=')
{
count++;
index += 3;
}
else
{
count++;
index++;
}
}
else if(str[index] == 'l')
{
if(str[index+1] == 'j')
{
count++;
index += 2;
}
else
{
count++;
index++;
}
}
else if(str[index] == 'n')
{
if(str[index+1] == 'j')
{
count++;
index += 2;
}
else
{
count++;
index++;
}
}
else if(str[index] == 's')
{
if(str[index+1] == '=')
{
count++;
index += 2;
}
else
{
count++;
index++;
}
}
else if(str[index] == 'z')
{
if(str[index+1] == '=')
{
count++;
index += 2;
}
else
{
count++;
index++;
}
}
else
{
count++;
index++;
}
}
cout << count;
}
'Algorithm > BOJ' 카테고리의 다른 글
[c++][BOJ][10799] 쇠막대기 (0) | 2021.11.15 |
---|---|
[c++][BOJ][1427] 소트인사이드 (0) | 2021.10.28 |
[c++][BOJ] 수들의 합 (0) | 2021.10.27 |
[c++][BOJ] 전자레인지 (0) | 2021.10.25 |
[c++][BOJ] 로프 (0) | 2021.10.25 |