kkkkk


私信TA

用户名:kkkkk

访问量:5940

签 名:

等  级
排  名 5945
经  验 1412
参赛次数 2
文章发表 9
年  龄 0
在职情况 学生
学  校 安徽财经大学
专  业

  自我简介:

TA的其他文章

解题思路:
用最传统的方法做吧,逐一判断。




注意事项:对数字的判断,引用单引号。





参考代码:

#include<stdio.h>

int main()

{   

   char a[100];

   int i;

   gets(a);

   int character=0,number=0,space=0,other=0;

   for(i=0;a[i]!='\0';i++)

   {

    if(a[i]>='a'&&a[i]<='z'||a[i]>='A'&&a[i]<='Z')

    character++;

    else if(a[i]>='0'&&a[i]<='9')   //此处的单引号少了,条件就无效了 

    number++;

    else if(a[i]==' ')

    space++;

    else

    other++;

   }

   printf("%d %d %d %d",character,number,space,other);

   return 0;

}



 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答

代码解释器

  评论区