C++ 实例 - 判断元音/辅音

C++ 教程 · 2019-02-26 11:44:50

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

实例

#include <iostream> using namespace std; int main() { char c; int isLowercaseVowel, isUppercaseVowel; cout << "输入一个字母: "; cin >> 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) cout << c << " 是元音"; else cout << c << " 是辅音"; return 0; }

以上程序执行输出结果为:

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

点击查看所有 C++ 教程 文章: https://www.codercto.com/courses/l/18.html

查看所有标签

The Algorithm Design Manual

The Algorithm Design Manual

Steve S. Skiena / Springer / 1998-8-1 / GBP 53.91

Contents u Techniques u Introduction to Algorithms u Correctness and Efficiency u Correctness u Efficiency u Expressing Algorithms u Keeping Score u The RAM Model of Computatio......一起来看看 《The Algorithm Design Manual》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

html转js在线工具
html转js在线工具

html转js在线工具