code4sk/c/sourcecode/朱森森带领的奇妙冒险/字符串1/统计大写辅音字母.cpp
2023-10-18 16:17:32 +08:00

29 lines
575 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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