Scanner sc = new Scanner(System.in);
//输入一个数字random
int random = sc.nextInt();
//随机在[0'26)产生一个数字
//int random = (int)(Math.random()*26);
//将数字转换成对应的ASCII编码
char ch = (char)('a'+random);
switch (ch){
case'a':
case'e':
case'i':
case'o':
case'u':
System.out.println("元音"+ch);break;
case'y':
case'w':
System.out.println("半元音"+ch);break;
default:
System.out.println("辅音"+ch);break;
}
判断字母是元音、辅音、半元音
最新推荐文章于 2023-11-29 00:12:58 发布