Christ


私信TA

用户名:christ

访问量:4709

签 名:

等  级
排  名 2717
经  验 2096
参赛次数 0
文章发表 9
年  龄 19
在职情况 学生
学  校 四川师范大学
专  业

  自我简介:

解题思路:

其他题解思路都不错,这里给大家提供一个简洁的代码供参考

注意事项:

参考代码:

#include<stdio.h>
int i,c,a;

int count(int c)
{
 int letter = 0, number = 0, blank = 0, others = 0;
 while ((c = getchar()) != '\n')
 {
  if (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z')
   letter++;
  else if (c >= '0' && c <= '9')
   number++;
  else if (c == ' ')
   blank++;
  else
   others++;
 }
 printf("%d %d %d %d", letter, number, blank, others);
 return 0;
}

int main()
{
 return count(c);
}


 

0.0分

0 人评分

  评论区