输入一串字符,统计元音字母个数

输入一串字符(长度不超过1000,以回车符结束),统计其中元音字母的个数。输出要求:输入一个整数,表示元音字母个数;输出单独占一行。

/*给的示例需要注意说明:‘A和’a'都是元音.*/

输入:Hello World!

输出:3

#include<stdio.h>
#include<math.h>
int vowel(char ch);
int main()
{
	char ch;
	int count;
	count = 0;
	while ((ch = getchar()) != '\n')
	{
		if (vowel(ch) == 1)
			count++;
	}
	printf("%d", count);
	return 0;
}
int vowel(char ch)
{
	if (ch == 'A' || ch == 'a' || ch == 'E' || ch == 'e' || ch == 'I' || ch == 'i' || ch == 'O' || ch == 'o' || ch == 'U' || ch == 'u')
		return 1;
	else
		return 0;
}

此处用到了‘输入一串字符’的方法,刚开始学,感觉有必要记住。

  • 1
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值