题目:
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 ss is Berlanese.
Input
The first line of the input contains the string ss consisting of |s||s| (1≤|s|≤1001≤|s|≤100) lowercase Latin letters.
Output
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).
Examples
Input
sumimasen
Output
YES
Input
ninja
Output
YES
Input
codeforces
Output
NO
Note
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.
题目大意:
a,e,i,o,u为元音。除去n,其他字母后方都要跟着一个元音字母菜符合要求。
代码:
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
char a[5]={'a','e','i','o','u'};
int main()
{
char ch[110];
int flag[110];
while(scanf("%s",ch)!=EOF)
{
int len=strlen(ch);
/*元音字母用1表示,n用2表示,其他字母用0表示*/
for(int i=0;i<len;i++)
{
//先判断这个字母是不是n
if(ch[i]=='n')
{
flag[i]=2;
}
//如果不是n,再判断是不是元音字母
else
{
for(int j=0;j<5;j++)
{
if(ch[i]!=a[j])//不是元音字母
{
flag[i]=0;
}
else
{
flag[i]=1;//是元音字母,注意只要判断出是元音字母了,就跳出这个小的for循环,不再与其他元音字母相比较
break;
}
}
}
}
int cnt=1;
for(int i=0;i<len;i++)
{
if(flag[i]==0)//若不是元音也不是n的字母后方根的不是元音字母,那么这个字符串一定是不成立的
if(flag[i+1]!=1)
cnt=0;
}
if(cnt)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return 0;
}