package zh.codegym.task.task09.task0923;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
/*
元音和辅音
*/
public class Solution {
public static char[] vowels = new char[]{'a', 'e', 'i', 'o', 'u'};
public static void main(String[] args) throws Exception {
char c = (char)System.in.read();
ArrayList<Character> vowel = new ArrayList<Character>();
ArrayList<Character> unvowel = new ArrayList<Character>();
while (c != '\n'){
if (c == ' '){
c = (char)System.in.read();
continue;
}
if (isVowel(c)){
vowel.add(c);
vowel.add(' ');
}
else {
unvowel.add(c);
unvowel.add(' ');
}
c = (char)System.in.read();
}
for (int i = 0; i < vowel.size(); i++)
System.out.print(vowel.get(i));
System.out.println();
for (int i = 0; i < unvowel.size(); i++)
System.out.print(unvowel.get(i));
}
public static boolean isVowel(char c) {
c = Character.toLowerCase(c); // 转换为小写
for (char d : vowels) // 在数组中查找元音
{
if (c == d)
return true;
}
return false;
}
}
package zh.codegym.task.task09.task0923;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
/*
元音和辅音
*/
public class Solution {
public static char[] vowels = new char[]{'a', 'e', 'i', 'o', 'u'};
public static void main(String[] args) throws Exception {
char c = (char)System.in.read();
ArrayList<Character> vowel = new ArrayList<Character>();
ArrayList<Character> unvowel = new ArrayList<Character>();
while (c != '\n'){
if (c == ' '){
c = (char)System.in.read();
continue;
}
if (isVowel(c)){
vowel.add(c);
vowel.add(' ');
}
else {
unvowel.add(c);
unvowel.add(' ');
}
c = (char)System.in.read();
}
for (int i = 0; i < vowel.size(); i++)
System.out.print(vowel.get(i));
System.out.println();
for (int i = 0; i < unvowel.size(); i++)
System.out.print(unvowel.get(i));
}
public static boolean isVowel(char c) {
c = Character.toLowerCase(c); // 转换为小写
for (char d : vowels) // 在数组中查找元音
{
if (c == d)
return true;
}
return false;
}
}