C语言编程:输入一串字符,统计其中大写英文字母个数
2个回答
展开全部
char str[1024];
int i = 0;
int count = 0;
//输入字符串
scanf("%s", str);
for (i = 0, count = 0; i < strlen(str); i++)
{
if ((str[i] >= 'A') && (str[i] <= 'Z')) //判断条件。
{
count ++; //记录个数
}
}
printf("Numbers of char which is before 'A' and 'Z' are %d\n", count);
int i = 0;
int count = 0;
//输入字符串
scanf("%s", str);
for (i = 0, count = 0; i < strlen(str); i++)
{
if ((str[i] >= 'A') && (str[i] <= 'Z')) //判断条件。
{
count ++; //记录个数
}
}
printf("Numbers of char which is before 'A' and 'Z' are %d\n", count);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询