Java implementation of the Blue Bridge Cup analog vowel word verification

Problem description
  Xiaoming very interested hello similar to this word, this word may be divided into four precisely, the first section by one or more letters consonant, vowel second segment of one or more letters, the first three segments of one or more letters consonant, vowel fourth paragraph of one or more letters.
  Given a word, to determine whether the word is such a word, if your output is yes, otherwise output no.
  Including vowels a, e, i, o, u, a total of five, are other consonants.
Input format
  input line contains a word, the word contains only lowercase letters.
Output format
  output answer, or to yes, or a no.
Sample Input
lanqiao
Sample Output
yes
Sample Input
world
Sample Output
no
evaluation scale and conventions used in Example
  use cases for all reviews, the number of letters in the word does not exceed 100.

package 第十三次模拟;

import java.util.ArrayList;
import java.util.Scanner;

public class Demo6元音 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();
		ArrayList<Character> list = new ArrayList<Character>();
		list.add('a');
		list.add('e');
		list.add('i');
		list.add('o');
		list.add('u');
		char [] str = s.toCharArray();
		boolean bool=false;
		int temp=0;
		for (int i = 0; i <str.length; i++) {
			if(bool){
				if(!list.contains(str[i])){
					i--;
					temp++;
					bool=false;
					continue;
				}
			}
			else{
				if(list.contains(str[i])){
					i--;
					temp++;
					bool=true;
					continue;
				}
			}
		} 
		if(temp==3){
			System.out.println("yes");
		}
		else{
			System.out.println("no");
		}
	}

}

Released 1472 original articles · won praise 10000 + · views 1.76 million +

Guess you like

Origin blog.csdn.net/a1439775520/article/details/104750280