题解 | #判断是元音还是辅音#
判断是元音还是辅音
http://www.nowcoder.com/practice/7eb4df4d52c44d309081509cf52ecbc4
#include<stdio.h> //A==65,E==69,I==73,O==79,U==85 int output(char a) { int ar[5] = {65, 69, 73, 79, 85}, t = 0; for (int i = 0; i < 5; i++) { if (a == ar[i] || a == ar[i] + 32) t = 1; //若a为元音返回值1 } return t; } int main() { char a; while (scanf("%c\n", &a) != EOF ) { if (output(a)) printf("Vowel\n"); else printf("Consonant\n"); } return 0; }