统计某一句话里面 元音字母的个数
2013-08-23 17:08
330 查看
应用switch 语句,
刚开始 把printf放在 while循环里面了,结果就悲剧了·····以后注意哈
#include<stdio.h> int main(void) { char ch; int a_ctl,e_ctl,i_ctl,o_ctl,u_ctl; a_ctl = e_ctl = i_ctl = o_ctl = u_ctl =0; printf(" Enter some text,and a # to quit\n" " I will tell you the number of the vowel\n" ); while((ch=getchar()) != '#') { switch(ch) { case 'A': case 'a': a_ctl++;break; case 'E': case 'e': e_ctl++;break; case 'I': case 'i': i_ctl++;break; case 'O': case 'o': o_ctl++;break; case 'U': case 'u': u_ctl++;break;// 保留此处的break,为了方便以后添加其他选项 default: break; } } printf("number of vowels: \n" "a:%d e:%d i:%d o:%d u:%d\n",a_ctl,e_ctl,i_ctl,o_ctl,u_ctl); return 0; }
刚开始 把printf放在 while循环里面了,结果就悲剧了·····以后注意哈
相关文章推荐
- 第13周Problem C: 统计元音字母个数
- Java之统计并输出文本文件中元音字母a,e,i,o,u的个数
- 第十三周OJ项目统计每个元音字母在字符串中出现的次数。
- OpenJudge计算概论-求字母的个数(统计元音字母个数)
- 统计字符串里面数字,字母,其他字符的出现次数
- 指针——统计元音字母
- 百度练习题 统计元音字母
- 统计每个元音字母在字符串中出现的次数
- 统计元音字母
- 第十三周 OJ平台-统计元音字母个数
- 第十三周 OJ平台统计元音字母个数
- [一天一项目]统计元音字母
- 第十三周OJ项目统计元音字母个数
- 统计一句话或者一个单词出现字母的个数
- 第十三周OJ项目3统计元音字母个数
- 统计文件里面字母a-z出现的次数
- Quzh[python]统计元音字母——输入一个字符串,统计处其中元音字母的数量。
- 第十三周oj平台项目三:统计元音字母
- 统计元音字母
- 第十三周OJ平台(3)统计元音字母个数