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

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

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

输入格式:

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

输出格式:

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

输入样例:

HELLO World!

输出样例:

4
#include<stdio.h>
int main(){
  int i,j=0,l=0,len=0;
  char a[80]={0},ch;
  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')
    j++;
    if(a[i]=='A'||a[i]=='E'||a[i]=='I'||a[i]=='O'||a[i]=='U')
    l++;
  }
  printf("%d",j-l);
 return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_42057358/article/details/84036440