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

C 语言教程 · 2019-02-20 16:44:06

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

英语有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 是辅音

点击查看所有 C 语言教程 文章: https://codercto.com/courses/l/17.html

查看所有标签

Web Design for ROI

Web Design for ROI

Lance Loveday、Sandra Niehaus / New Riders Press / 2007-10-27 / USD 39.99

Your web site is a business--design it like one. Billions of dollars in spending decisions are influenced by web sites. So why aren't businesses laser-focused on designing their sites to maximize thei......一起来看看 《Web Design for ROI》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

SHA 加密
SHA 加密

SHA 加密工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具