首页 > 其他 > 详细

字符个数

时间:2018-10-23 19:57:03      阅读:124      评论:0      收藏:0      [点我收藏+]

输入一行字符,分别统计出其中英文字母、数字、空格和其他字符的个数。

 

输入

一行字符

输出

统计值

样例输入

aklsjflj123 sadf918u324 asdf91u32oasdf/.‘;123

样例输出

23 16 2 4
#include <stdio.h>
int main()
{
 int letter=0,space=0,number=0,others=0;
 char nextchar;
 for(;nextchar!=\n;)
 {
  scanf("%c",&nextchar);
  if((a<=nextchar&&nextchar<=z)||(A<=nextchar&&nextchar<=Z))
   letter++;
  else if(nextchar== )
   space++;
  else if(0<=nextchar&&nextchar<=9)
   number++;
  else
   others++;
 }
 printf("%d %d %d %d\n",letter,number,space,--others);
    return 0;
}

 

字符个数

原文:https://www.cnblogs.com/Lazy-Cat/p/9838261.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!