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

查看所有标签

Head First WordPress

Head First WordPress

Siarto Jeff / O'Reilly Media / 2010-02-15 / USD 34.99

Whether you're promoting your business or writing about your travel adventures, "Head First WordPress" will teach you not only how to make your blog look unique and attention-grabbing, but also how to......一起来看看 《Head First WordPress》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试