题解 | #判断是元音还是辅音#
判断是元音还是辅音
https://www.nowcoder.com/practice/7eb4df4d52c44d309081509cf52ecbc4
#include <stdio.h> #include <string.h> int main() { char ch; char array[] = {"AaEeIiOoUu"}; int sz = sizeof(array) / sizeof(array[0]); while (~scanf(" %c", &ch)) { //strchr就是在array中寻找字符ch //如果找到了返回下标的地址,找不到放回空指针 //null在c语言中是0 if (strchr(array,ch)) { printf("Vowel\n"); } else { printf("Consonant\n"); } } return 0; }