题解 | 判断是元音还是辅音

判断是元音还是辅音

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;
}

全部评论

相关推荐

zaakfung:26届不应该春招吗 为啥还实习
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务