[백준] Baekjoon Online Judge
문제
The Vowels are a, e, i, o and u, and possibly y. People disagree on whether y is a vowel or not. Unfortunately for you, you have been tasked with counting the number of vowels in a word. You'll have to count how many vowels there are assuming y is a vowel, and assuming y is not.
입력
The single line of input contains a string of at least one and at most 50 lowercase letters.
출력
Output two space-separated integers. The first is the number of vowels assuming y is not a vowel, the second is the number of vowels assuming y is a vowel.
풀이
#include <iostream>
using namespace std;
char mo[6] = { 'a', 'e', 'i', 'o', 'u', 'y' };
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
string s;
cin >> s;
int cnt = 0;
int yCnt = 0;
for (int i = 0; i < s.length(); i++) {
for (char c : mo) {
if (s[i] == c) {
if (c == 'y') yCnt++;
cnt++;
break;
}
}
}
cout << cnt - yCnt << ' ' << cnt << '\n';
return 0;
}
'백준 > C++' 카테고리의 다른 글
[Baekjoon/C++] 17598번 - Animal King Election (1) | 2024.12.18 |
---|---|
[Baekjoon/C++] 32775번 - 가희와 4시간의 벽 1 (0) | 2024.12.10 |
[Baekjoon/C++] 16946번 - 벽 부수고 이동하기 4 (0) | 2024.12.07 |
[Baekjoon/C++] 20303번 - 할로윈의 양아치 (0) | 2024.12.05 |
[Baekjoon/C++] 32498번 - Call for Problems (0) | 2024.12.04 |