Algorithm
[BOJ 2941] 크로아티아 알파벳
승우승
2019. 1. 7. 16:07
반응형
문제출처
https://www.acmicpc.net/problem/2941
순서대로 if로 묶어주면 된다
소스코드
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 32 | #include <iostream> #include <string.h> #include <string> using namespace std; int main(void) { ios_base::sync_with_stdio(false); cin.tie(0); string str; int ret = 0; cin >> str; for (int i = 0; i < str.size(); i++) { ret++; if (str[i] == 'c' && (str[i + 1] == '=' || str[i + 1] == '-')) i++; else if (str[i] == 'd') { if (str[i + 1] == '-') i++; else if (str[i + 1] == 'z' && str[i + 2] == '=') i += 2; } else if ((str[i] == 'l' || str[i] == 'n') && str[i + 1] == 'j') i++; else if ((str[i] == 's' || str[i] == 'z') && str[i + 1] == '=') i++; } cout << ret; return 0; } | cs |
반응형