C语言统计字符串中小写字母个数:使用while和if语句
#include <stdio.h>
int main() {
char str[100];
int i = 0, count = 0;
printf('请输入字符串:');
scanf('%s', str);
while (str[i] != '\0') {
if (str[i] >= 'a' && str[i] <= 'z') {
count++;
}
i++;
}
printf('小写字母的个数为:%d', count);
return 0;
}
原文地址: https://www.cveoy.top/t/topic/nXak 著作权归作者所有。请勿转载和采集!