题目描述
给定一个单词,请计算这个单词中有多少个元音字母,多少个辅音字母。
元音字母包括 a, e, i, o, u,共五个,其他均为辅音字母。
输入描述
输入格式:
输入一行,包含一个单词,单词中只包含小写英文字母。单词中的字母个数不超过 100。
输出描述
输出两行,第一行包含一个整数,表示元音字母的数量。
第二行包含一个整数
#include <iostream>
using namespace std;int main() {string s;int ans = 0,d=0;cin >> s;for (int i = 0; i < s.size(); i++) { char c = s[i];if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' ){ // 可选:添加大写元音判断ans++;}elsed++;}cout << ans << endl<<d;return 0;
}
,表示辅音字母的数量。