英文辅音字母是除A、E、I、O、U以外的字母。本题要求编写程序,统计给定字符串中大写辅音字母的个数。
输入格式:
输入在一行中给出一个不超过80个字符、并以回车结束的字符串。
输出格式:
输出在一行中给出字符串中大写辅音字母的个数。
输入样例:
HELLO World!
输出样例:
4
#include<stdio.h>
int main(void){
char str[80];
int count=0,i=0;
while((str[i]=getchar( ))!='\n')
i++;
for(i=0; str[i]!='\n'; i++){
if(str[i]>='A' && str[i]<='Z'){
switch(str[i]){
//若为不满足条件的大写字母,直接跳出 switch 语句
case 'A':case 'E':case 'I':case 'O':case 'U':break;
default :count++;break;
}
}
}
printf("%d\n",count);
return 0;
}