코드포스(CodeForce)
Educational Codeforces Round 38 (Rated for Div. 2) - Word Correction
cepiloth
2018. 8. 17. 18:29
반응형
1. 문제
2. 알고리즘
키워드 - 구현
문제에 제약 사항을 정확히 파악 해야한다.
In this problem letters a, e, i, o, u and y are considered to be vowels.
3. 코드
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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | #include<map> #include<algorithm> #include<vector> #include<string> #include<iostream> #include<set> using namespace std; bool isMoum(char ch) { if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' || ch == 'y') { return true; } return false; } int main() { int n; cin >> n; string str; cin >> str; string result; int size = str.size(); for (int i = 0; i < size; i++) { if (isMoum(str[i])) { int count = 0; for (int j = i + 1; j < size; j++) { if (isMoum(str[j])) { //result += str[i]; count++; } else break; } result += str[i]; i = i + count; } else { result += str[i]; } } cout << result << endl; return 0; } | cs |
반응형