习题7-6 统计大写辅音字母 (15分)
作者:互联网
英文辅音字母是除A
、E
、I
、O
、U
以外的字母。本题要求编写程序,统计给定字符串中大写辅音字母的个数。
输入格式:
输入在一行中给出一个不超过80个字符、并以回车结束的字符串。
输出格式:
输出在一行中给出字符串中大写辅音字母的个数。
输入样例:
HELLO World!
输出样例:
#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; }4
//注意字符会自动添加'\0'多一个字符结尾
标签:count,15,int,字母,大写,str,习题,辅音 来源: https://www.cnblogs.com/wven/p/12727147.html