kkkkk


私信TA

用户名:kkkkk

访问量:5932

签 名:

等  级
排  名 5834
经  验 1411
参赛次数 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 人评分

  评论区