zoukankan      html  css  js  c++  java
  • Codeforces Round #497 (Div. 2) A. Romaji

    A. Romaji
    time limit per test
    2 seconds
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    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
    Copy
    sumimasen
    
    output
    Copy
    YES
    
    input
    Copy
    ninja
    
    output
    Copy
    YES
    
    input
    Copy
    codeforces
    
    output
    Copy
    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.



    判断字符串中除字母‘n’外每个非元音字母后是否有元音字母(为空也不行)

    没有错

    全有对

    ‘n’后可跟任意字母 包括空字母

    #include <iostream>
    using namespace std;
    
    int main()
    {
    	string a;
    	cin>>a;
    	
    	for(int i = 0; i < a.length(); i++)
    	{
    		if(a[i] == 'n')
    			continue;
    			
    		else if(a[i] != 'a' && a[i] != 'e' && a[i] != 'i' && a[i] != 'o' && a[i] != 'u')
    		{
    			if(a[i + 1] != 'a' && a[i + 1] != 'e' && a[i + 1] != 'i' && a[i + 1] != 'o' && a[i + 1] != 'u')
    			{
    				cout<<"NO"<<endl;
    				goto l1;
    			}
    		}
    	}
    	cout<<"YES"<<endl;
    	
    	l1:
    	return 0;
    }
    


  • 相关阅读:
    Redis基础知识补充及持久化、备份介绍
    Redis基础认识及常用命令使用
    Docker实战(7):Docker无日志(无*-json.log文件)
    Linux实战(11):Centos安装Jenkins
    Linux实战(13):Centos8 同步时间
    Docker实战(6): 导出docker镜像离线包
    Linux实战(13):Centos8安装FFmpeg
    Linux实战(12):解决Centos7 docker 无法自动补全
    Linux实战(11):Centos后期添加网卡配置
    Linux实战(11):配置PPPOE拨号
  • 原文地址:https://www.cnblogs.com/zeolim/p/12270590.html
Copyright © 2011-2022 走看看