题解 | #判断是元音还是辅音#
判断是元音还是辅音
https://www.nowcoder.com/practice/7eb4df4d52c44d309081509cf52ecbc4
#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main() {
char aiphabet[10] = { 'A', 'E', 'I', 'O', 'U', 'a', 'e', 'i', 'o', 'u' };
char steam;
while (scanf("%c", &steam) != EOF) {
getchar();//用于抵消\n
int i = 0;
for (i = 0; i <= 10;
i++) { //数组虽然只有9位,但是刻意多出一位先让他循环前9位,如果都没有则直接打印conson
if (steam == aiphabet[i]) {
printf("Vowel\n");
break;//当他循环到相等时立马跳出循环,不然steam就算打印出来了的vowel,也会一直增加到10,又打印出接下来的
} else if (i > 9) {
printf("Consonant\n");
}
}
}
return 0;
}
查看6道真题和解析