我以初学者的视角出发,用switch语句实现判断。注释已经讲明了基本原理。

#include <stdio.h>int main() {char ch;

while (scanf("%c",&ch)!=EOF) {
    getchar();//getchar用于吸收回车,以免switch连回车键也判断了
    switch (ch) {
        case 'A':
        case 'E':
        case 'I':
        case 'O':
        case 'U':
        case 'a':
        case 'e':
        case 'i':
        case 'o':
        case 'u':printf("Vowel\n");//十种情况定为元音
        break;
        default:printf("Consonant\n");//以上都不成立时,则为非元音
    }
}
return 0;

}