习题7-6 统计大写辅音字母 (15point(s)).c

英文辅音字母是除AEIOU以外的字母。本题要求编写程序,统计给定字符串中大写辅音字母的个数。

输入格式:

输入在一行中给出一个不超过80个字符、并以回车结束的字符串。

输出格式:

输出在一行中给出字符串中大写辅音字母的个数。

输入样例:

HELLO World!

输出样例:

4
//   Date:2020/3/24
//   Author:xiezhg5
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
	int i,len=0,count=0;
	char ch,a[80];
	ch=getchar();
	for(i=0;ch!='\n';i++)
	{
		a[i]=ch;
	    len++;
		ch=getchar();
	}
	for(i=0;i<len;i++)
	{
		if(a[i]>='A'&&a[i]<='Z'&&a[i]!='A'&&a[i]!='E'&&a[i]!='I'&&a[i]!='O'&&a[i]!='U')
		count++;
	}
	printf("%d\n",count);
	return 0;
}
发布了131 篇原创文章 · 获赞 94 · 访问量 2957

猜你喜欢

转载自blog.csdn.net/qq_45645641/article/details/105081920