题解 | 判断是元音还是辅音
判断是元音还是辅音
https://www.nowcoder.com/practice/7eb4df4d52c44d309081509cf52ecbc4
#include <stdio.h>
#include <ctype.h>
#include <string.h>
int isvowel(char c){
char vowels[]="AEIOUaeiou";
return strchr(vowels, c) != NULL;
}
int main(){
char character ;
while ((scanf("%c",&character))!=EOF){
if (character == '\n') {
continue;
}
if (!isalpha(character)) {
printf("'%c' is not a letter.\n",character);
continue;
}
if (isvowel(character)) {
printf("Vowel\n");
}
if (!isvowel(character)) {
printf("Consonant\n");
}
}
return 0;
}