본문 바로가기

Coding/백준 온라인 저지 (Baekjoon Online Judge)

백준 온라인 저지 (Baekjoon Online Judge) - 1264번: 모음의 개수

https://www.acmicpc.net/problem/1264

 

1264번: 모음의 개수

입력은 여러 개의 테스트 케이스로 이루어져 있으며, 각 줄마다 영어 대소문자, ',', '.', '!', '?', 공백으로 이루어진 문장이 주어진다. 각 줄은 최대 255글자로 이루어져 있다. 입력의 끝에는 한 줄

www.acmicpc.net

 

#include <iostream>
#include <string>
using namespace std;

bool is_vowel(char ch) {
	switch (ch) {
	case 'a':
	case 'e':
	case 'i':
	case 'o':
	case 'u':
	case 'A':
	case 'E':
	case 'I':
	case 'O':
	case 'U':
		return true;
	default:
		return false;
	}
}

int main() {
	string str;
	int len;
	int count = 0;

	while (true) {
		getline(cin, str);
		if (str == "#") break;
		len = str.length();
		for (int i = 0; i < str.length(); i++) {
			if (is_vowel((char)str[i]))
				count++;
		}
		cout << count << endl;
		count = 0;
	}
}