题目链接:http://codeforces.com/contest/1008/problem/A
题意就是给了一个字符串,除了n以外每个辅音字母后面都要跟一个元音字母,而且除了n意外的辅音字母不能是结尾。
AC代码:
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
string ch;
cin>>ch;
int a = ch.length();
if(ch[a-1] != 'a' && ch[a-1] != 'e' && ch[a-1] != 'i' && ch[a-1] != 'o' && ch[a-1] != 'u' && ch[a-1] != 'n'){
printf("NO\n");
return 0;
}
for(int i=0;i<a-1;i++){
if(ch[i] != 'a' && ch[i] != 'e' && ch[i] != 'i' && ch[i] != 'o' && ch[i] != 'u' && ch[i] != 'n'){
if(ch[i+1] != 'a' && ch[i+1] != 'e' && ch[i+1] != 'i' && ch[i+1] != 'o' && ch[i+1] != 'u'){
printf("NO\n");
return 0;
}
}
}
printf("YES\n");
return 0;
}