英文輔音字母是除A
、E
、I
、O
、U
以外的字母。本題要求編寫程序,統計給定字符串中大寫輔音字母的個數。
輸入格式:
輸入在一行中給出一個不超過80個字符、並以回車結束的字符串。
輸出格式:
輸出在一行中給出字符串中大寫輔音字母的個數。
輸入樣例:
HELLO World!
輸出樣例:
4
//注意字符會自動添加'\0'多一個字符結尾
#include<stdio.h>
#include<string.h>
int main()
{
int count=0;
int i;
char str[81];
gets(str);
for(i=0;str[i]!='\0';i++)
{
if(str[i]>='A'&&str[i]<='Z')
{
if(str[i]=='A'||str[i]=='E'||str[i]=='I'||str[i]=='O'||str[i]=='U')
{
continue;
}
else
{
count++;
}
}
}
printf("%d",count);
return 0;
}