#include int main() { char str[100],i; int upper = 0, lower = 0, number = 0, special = 0,whitesp=0; printf("enter string"); gets(str); for (i = 0; i < str[i]!='\0'; i++) { if (str[i] >= 'A' && str[i] <= 'Z') upper++; else if (str[i] >= 'a' && str[i] <= 'z') lower++; else if (str[i]>= '0' && str[i]<= '9') number++; else if(str[i]==' ') whitesp++; else special++; } printf("Upper case letters: %d</p><p>",upper); printf("lower case letters: %d</p><p>",lower); printf("Numbers: %d</p><p>",number); printf("whitespace: %d</p><p>",whitesp); printf("sp chararcter: %d</p><p>",special); return 0; }
以上是使用C语言计算一个句子中的空格、大写字母和小写字母的数量的详细内容。更多信息请关注PHP中文网其他相关文章!