为了账号安全,请及时绑定邮箱和手机立即绑定

输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数。我写的代码为什么不行啊

输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数。我写的代码为什么不行啊

C
a12svs 2020-03-11 15:41:30
#include<stdio.h>#include <string.h>int main(){        char str[50];    int a,b,c,d,i;    gets(str);    for(i=0;i<strlen(str);i++){                 if(str[i]>='a'&&str[i]<='z'||str[i]>='A'&&str[i]<='Z'){            a++;        }        else if(str[i]==' '){            b++;                    }        else if(str[i]>='0'&&str[i]<='9')        c++;        else        d++;    }    printf("%d %d %d %d",a,b,c,d);}
查看完整描述

目前暂无任何回答

  • 0 回答
  • 0 关注
  • 830 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信