BOJ 10987번 단위 문제

문자열에 관한 간단한 문제다.

string을 입력받고 인덱스로 한글자씩 살피면서 'a' 'e' 'i' 'o' 'u'이면 count값을 1씩 증가시킨다.

모두 살핀 다음 출력하면 된다.

10987.cpp

#include <iostream>
using namespace std;

bool check(char c) {
    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
        return true;
    }
    return false;
}

int main() {
    string s;
    cin >> s;
    int stringSize = s.size();
    int count = 0;
    for (int i = 0; i < stringSize; i++) {
        if (check(s[i])) {
            count++;
        }
    }
    cout << count;
}

'알고리즘 & SQL > 백준(BOJ)' 카테고리의 다른 글

백준 14753번 : MultiMax C++  (0) 2018.11.02
백준 9086번 : 문자열 C++  (0) 2018.11.02
백준 1427번 : 소트인사이드 C++  (0) 2018.11.02
백준 2851번 : 슈퍼 마리오 C++  (1) 2018.11.02
백준 2998번 : 8진수 C++  (0) 2018.10.31

+ Recent posts