c语言,求助大神,谢谢! 统计输入的字符串中小写字母、大写字母、数字及其他字符的个数。(定义一个字

c语言,求助大神,谢谢!
统计输入的字符串中小写字母、大写字母、数字及其他字符的个数。(定义一个字符数组存放字符串)

#include<stdio.h>
#include<stdlib.h>

int main()
{
    char s[128];
    int a;
    int A;
    int n;
    int other;
    a=A=n=other=0;
    while(gets(a))
    {
        for(i=0;a[i]!='\n';i++)
        {
            if(a[i]>='a'&&a[i]<='z') a++;
            else if(a[i]>='A'&& a[i]<='Z') A++;
            ele if(a[i]>='0'&&a[i]<='9')n++;
            else other ++;
        }
        printf("%d %d %d %d:",a,A,n,other);
    }
    return 0;
}

温馨提示:答案为网友推荐,仅供参考
相似回答
大家正在搜