zzulioj1094c语言版答案,ZZULIOJ 1094: 统计元音(函数专题)

题目描述

输入一个字符串,统计其中元音字母的个数。要求使用函数vowel()用来判断是否为元音,其余功能在main()函数中实现。

int vowel(char ch)

{

//如果ch是元音,返回1,否则返回0

}

本题如果是C/C++代码提交,只需要提交vowel函数的定义部分,提交其它内容,编译出错。

输入

输入一个字符串,长度不超过1000,以回车符结束。

输出

输出一个整数,表示元音字母个数。输出单独占一行。

样例输入

Hello world!

样例输出

3

tips:

1 元音字母除了 a e i o u 还有 A E I O U

2 getchar()返回当前读取的字符,可以读取回车   scanf()返回读取成功的个数

#include

#include

#include

int vowel(char ch)

{

//如果ch是元音,返回1,否则返回0

switch (ch)

{

case 'a':

case 'e':

case 'i':

case 'o':

case 'u':

case 'A':

case 'E':

case 'I':

case 'O':

case 'U':

return 1;

break;

default:

return 0;

break;

}

}

int main(){

char ch;

int count = 0;

while ((ch=getchar())!='\n')

{

count += vowel(ch);

}

printf("%d",count);

}

f824fbc7b4b984ad67077a1de5fe34ae.png

068be7e19a8fd7ea1cc73db7ddbb42c1.png

马赛克|

发布了122 篇原创文章 · 获赞 58 · 访问量 4万+

私信

关注

标签:1094,case,ch,int,返回,ZZULIOJ,vowel,元音

来源: https://blog.csdn.net/qq_39112646/article/details/104080510

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值