输入一段字符串计算以元音开头的字母有几个
2016-08-10 22:18
381 查看
#include <iostream> #include <string> int main() { using namespace std; unsigned a =0 ,b = 0,c = 0,d=0; cout << "输入单词: "; string tt; while (cin >> tt && "q" != tt) { ++a; char first_char = tt[0]; if (!isalpha(first_char)) { ++b; } else if ('a' == first_char || 'A' == first_char || 'o' == first_char || 'O' == first_char || 'u' == first_char || 'U' == first_char || 'e' == first_char || 'E' == first_char || 'i' == first_char || 'I' == first_char ) { ++c; } else { ++d; } } cout << "总共输入: " << a << " 个字符串。" << endl; cout << "元音开头的单词有:" << c << endl; cout << "不是以字母开头的有:" << b << endl; cout << "剩余的有:" << d << endl; cout << endl; return 0; }
相关文章推荐
- 笔试题——编写java程序:输入一个字符串,判断有几个英文字母,有几个数字,有几个其它的字符
- 输入5个字符串,打印出"b"开头的字母
- P51 第13题 输入一段字符串,*键停止,统计数字和字母个数
- 验证用户输入的字符串中时候只含有数字,字母或汉字.总长度为6~~20,并且以字母,汉字开头
- 计算输入的字符串中字母,数字。。。的数量
- 输入前几个字母,用箭头就能找出开头字母相同的历史命史
- 输入读入一个String 序列,计算元音字母的个数,然后再顺序输出--C++
- 求一段字符串中元音字母的个数-C语言经典代码-编程
- 输入一段字符,判断字符串中字母的个数,数字的个数和其他字符个数
- 输入一段字符串和要判断的字母,然后判定该字母是否在字符串里面,给出相应的提示
- 输入一段字符串,无论是否有重复元素出现,都只打印一次出现过的大写字母和小写字母, 且按字母表顺序打印。(如输入AaAa!<-131->!zZzZ, 只打印A Z a z)
- python计算一段字符串字母的和(a,b分别为1,2)
- 华为计算字符个数写出一个程序,接受一个有字母和数字以及空格组成的字符串,和一个字符,然后输出输入字符串中含有该字符的个数。不区分大小写。
- 从键盘输入字符串计算字母出现的次数
- 输入一个字符串,计算该字符串中字母的个数,并将大写字母转化为小写字母,小写字母转化为大写字母
- 华为机试: 计算字符串的相似度、输入一行字符,分别统计出包含英文字母、空格、数字和其它字符的个数
- Quzh[python]统计元音字母——输入一个字符串,统计处其中元音字母的数量。
- c语言初学--计算字符串中数字的最大长度并提取 以及输入两个子串 提取分别以这为开头和结尾的字符串
- 函数 Swift 使用函数多个返回值的特点完成一个count函数,该函数用于计算一个字符串中元音、辅音以及其他字母的个数。
- 345. Reverse Vowels of a String | 逆置字符串中的元音字母