https://www.lucien.ink/archives/305/
http://codeforces.com/contest/1008/problem/A
Vitya has just started learning Berlanese language. It is known that Berlanese uses the Latin alphabet. Vowel letters are “a”, “o”, “u”, “i”, and “e”. Other letters are consonant.
In Berlanese, there has to be a vowel after every consonant, but there can be any letter after any vowel. The only exception is a consonant “n”; after this letter, there can be any letter (not only a vowel) or there can be no letter at all. For example, the words “harakiri”, “yupie”, “man”, and “nbo” are Berlanese while the words “horse”, “king”, “my”, and “nz” are not.
Help Vitya find out if a word s s is Berlanese.
The first line of the input contains the string s s consisting of |s| | s | ( 1≤|s|≤100 1 ≤ | s | ≤ 100 ) lowercase Latin letters.
Print “YES” (without quotes) if there is a vowel after every consonant except “n”, otherwise print “NO”.
You can print each letter in any case (upper or lower).
sumimasen
YES
ninja
YES
codeforces
NO
In the first and second samples, a vowel goes after each consonant except “n”, so the word is Berlanese.
In the third sample, the consonant “c” goes after the consonant “r”, and the consonant “s” stands on the end, so the word is not Berlanese.
问是否除了n
以外的辅音字母后面都有一个元音字母。
#include
char str[1007];
bool vis[1007];
int main() {
std::cin >> str;
vis['a'] = vis['e'] = vis['i'] = vis['o'] = vis['u'] = true;
for (int i = 0; str[i]; i++) {
if (!vis[str[i]] && str[i] != 'n') {
if (!vis[str[i + 1]]) return 0 * puts("NO");
}
}
puts("YES");
return 0;
}