1. 编程学习网 > 编程教程 > C语言教程 > C语言实例-判断元音/辅音

C语言实例-判断元音/辅音

C 语言实例

判断输入的字母是元音,还是辅音。

英语有26个字母,元音只包括 a、e、i、o、u 这五个字母,其余的都为辅音。y是半元音、半辅音字母,但在英语中都把他当作辅音。

实例

#include <stdio.h> int main(){ char c; int isLowercaseVowel, isUppercaseVowel; printf("输入一个字母: "); scanf("%c",&c); // 小写字母元音 isLowercaseVowel = (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'); // 大写字母元音 isUppercaseVowel = (c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U'); // if 语句判断 if (isLowercaseVowel || isUppercaseVowel) printf("%c 是元音", c); else printf("%c 是辅音", c); return 0; }

运行结果:

输入一个字母: G
G 是辅音

本文由IT教学网整理发布,转载请注明出处:http://www.clang.cc//jiaocheng/cyuyan/1119.html

联系我们

在线咨询:点击这里给我发消息

咨询电话:400-998-2681

工作时间:7*24小时无休