题解 | 判断是元音还是辅音
判断是元音还是辅音
https://www.nowcoder.com/practice/7eb4df4d52c44d309081509cf52ecbc4
#include <stdio.h>
#include <ctype.h> // 使用 tolower 函数
int main() {
char ch;
while (scanf(" %c", &ch) != EOF) {
// 先统一转成小写,这样 case 减半,逻辑更清晰
switch (tolower(ch)) {
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
printf("Vowel\n");
break;
default:
printf("Consonant\n");
}
}
return 0;
}
查看9道真题和解析