Chinaunix首页 | 论坛 | 博客
  • 博客访问: 160014
  • 博文数量: 35
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 401
  • 用 户 组: 普通用户
  • 注册时间: 2014-11-28 14:09
文章分类

全部博文(35)

文章存档

2015年(27)

2014年(8)

分类: C/C++

2015-08-03 12:52:54


点击(此处)折叠或打开

  1. #include "stdio.h"
  2.   main()
  3.   {char c;
  4.   int letters=0,space=0,digit=0,others=0;
  5.   printf("please input some characters\n");
  6.   while((c=getchar())!='\n')
  7.   {
  8.   if(c>='a'&&c<='z'||c>='A'&&c<='Z')
  9.   letters++;
  10.   else if(c==' ')
  11.   space++;
  12.   else if(c>='0'&&c<='9')
  13.   digit++;
  14.   else
  15.   others++;
  16.   }
  17.   printf("all in all:char=%d space=%d digit=%d others=%d\n",letters,
  18.   space,digit,others);
  19.   }

阅读(1718) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~