๐ ๊ณต๋ถํ๋ ์ง์ง์ํ์นด๋ ์ฒ์์ด์ง?
[BAEKJOON C++] 10987_๋ชจ์์ ๊ฐ์ ๋ณธ๋ฌธ
728x90
๋ฐ์ํ
์ํ๋ฒณ ์๋ฌธ์๋ก๋ง ์ด๋ฃจ์ด์ง ๋จ์ด๊ฐ ์ฃผ์ด์ง๋ค.
์ด๋, ๋ชจ์(a, e, i, o, u)์ ๊ฐ์๋ฅผ ์ถ๋ ฅํ๋ ํ๋ก๊ทธ๋จ์ ์์ฑํ์์ค.
์ ๋ ฅ
์ฒซ์งธ ์ค์ ๋จ์ด๊ฐ ์ฃผ์ด์ง๋ค.
๋จ์ด์ ๊ธธ์ด๋ 1๋ณด๋ค ํฌ๊ฑฐ๋ ๊ฐ๊ณ , 100๋ณด๋ค ์๊ฑฐ๋ ๊ฐ์ผ๋ฉฐ,
์ํ๋ฒณ ์๋ฌธ์๋ก๋ง ์ด๋ฃจ์ด์ ธ ์๋ค.
์ถ๋ ฅ
์ฒซ์งธ ์ค์ ๋ชจ์์ ๊ฐ์๋ฅผ ์ถ๋ ฅํ๋ค.
// [10987] ๋ชจ์์ ๊ฐ์
/*
์ํ๋ฒณ ์๋ฌธ์๋ก๋ง ์ด๋ฃจ์ด์ง ๋จ์ด๊ฐ ์ฃผ์ด์ง๋ค.
์ด๋, ๋ชจ์(a, e, i, o, u)์ ๊ฐ์๋ฅผ ์ถ๋ ฅํ๋ ํ๋ก๊ทธ๋จ์ ์์ฑํ์์ค.
์
๋ ฅ
์ฒซ์งธ ์ค์ ๋จ์ด๊ฐ ์ฃผ์ด์ง๋ค.
๋จ์ด์ ๊ธธ์ด๋ 1๋ณด๋ค ํฌ๊ฑฐ๋ ๊ฐ๊ณ , 100๋ณด๋ค ์๊ฑฐ๋ ๊ฐ์ผ๋ฉฐ,
์ํ๋ฒณ ์๋ฌธ์๋ก๋ง ์ด๋ฃจ์ด์ ธ ์๋ค.
์ถ๋ ฅ
์ฒซ์งธ ์ค์ ๋ชจ์์ ๊ฐ์๋ฅผ ์ถ๋ ฅํ๋ค.
*/
#define _CRT_SECURE_NO_WARNINGS
// ํ์ค ์คํธ๋ฆผ์์ ์ฝ๊ธฐ ๋ฐ ์ฐ๊ธฐ๋ฅผ ์ ์ดํ๋ ๊ฐ์ฒด๋ฅผ ์ ์ธ
#include <iostream>
#include <algorithm> // find
#include <string>
#include <cmath> // abs
#include <vector>
#include <queue>
using namespace std;
int main() {
string str;
cin >> str;
int result = 0;
for (int i = 0; i < str.length(); i++) {
if (str[i] == 'a') {
result += 1;
}
else if (str[i] == 'e') {
result += 1;
}
else if (str[i] == 'i') {
result += 1;
}
else if (str[i] == 'o') {
result += 1;
}
else if (str[i] == 'u') {
result += 1;
}
}
cout << result;
return 0;
}
728x90
๋ฐ์ํ
'๐ฆฅ ์ฝํ > BAEKJOON' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[BAEKJOON C++] 10808_์ํ๋ฒณ ๊ฐ์ (0) | 2023.08.09 |
---|---|
[BAEKJOON C++] 4458_์ฒซ ๊ธ์๋ฅผ ๋๋ฌธ์๋ก (0) | 2023.08.09 |
[BAEKJOON C++] 3058_์ง์๋ฅผ ์ฐพ์๋ผ (0) | 2023.08.08 |
[BAEKJOON C++] 10953_A+B - 6 (0) | 2023.08.05 |
[BAEKJOON C++] 2744_๋์๋ฌธ์ ๋ฐ๊พธ๊ธฐ (0) | 2023.08.05 |
Comments