Codeforces Beta Round #70 (Div. 2) A : Haiku
問題概要
文字列が3行与えられる。各列に含まれる母音の数が5,7,5になっているかどうか判定する問題。
acceptされたコード
計算量O(strlen)。
#include <cstdio> using namespace std; const int MAX_L = 100; char buf[MAX_L + 1]; bool is_vowel(char ch){ const char vs[] = "aeiou"; for(int i=0; vs[i]; i++){ if(ch == vs[i]){ return true; } } return false; } int main(){ int cs[] = {5, 7, 5}; bool ok = true; for(int i=0; i<3; i++){ scanf("%[^\n]%*c", buf); int cnt = 0; for(int j=0; buf[j]; j++){ if(is_vowel(buf[j])){ cnt++; } } ok &= cnt == cs[i]; } puts(ok ? "YES" : "NO"); return 0; }