字符统计

Time Limit: 1 Sec  Memory Limit: 64 MB
Submit: 421  Solved: 92
[Submit][Status][Web Board]

Description

给出一串字符,要求统计出里面的字母、数字、空格以及其他字符的个数。字母:A, B, ..., Z、a, b, ..., z组成数字:0, 1, ..., 9 空格:" "(不包括引号) 剩下的可打印字符全为其他字符。

Input

测试数据有多组。每组数据为一行(长度不超过100000)。数据至文件结束(EOF)为止。

Output

每组输入对应一行输出。包括四个整数a b c d,分别代表字母、数字、空格和其他字符的个数。

Sample Input

A0 ,

Sample Output

1 1 1 1

HINT

 #include <iostream>
#include <string>
#include <stdio.h>
using namespace std;
char s[];
int main()
{
while( cin.getline(s,,'\n')){
int a=,b=,c=,d=;
for(int i=;s[i]!='\0';i++){
if( ('a'<=s[i] && s[i]<='z') || ('A'<=s[i] && s[i]<='Z') )
a++;
else if( ''<=s[i] && s[i]<='' )
b++;
else if( s[i]==' ' )
c++;
else
d++;
}
cout<<a<<' '<<b<<' '<<c<<' '<<d<<endl;
}
return ;
}

Freecode : www.cnblogs.com/yym2013

ytu 1910:字符统计(水题)的更多相关文章

  1. ytu 1998:C语言实验——删除指定字符(水题)

    C语言实验——删除指定字符 Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 327  Solved: 211[Submit][Status][Web Boa ...

  2. Codeforces Round #449 (Div. 2)-897A.Scarborough Fair(字符替换水题) 897B.Chtholly's request(处理前一半) 897C.Nephren gives a riddle(递归)

    A. Scarborough Fair time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  3. ytu 1304:串的简单处理(水题)

    串的简单处理 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 39  Solved: 11[Submit][Status][Web Board] Desc ...

  4. ytu 1052: 写一函数,将两个字符串连接(水题,指针练习)

    1052: 写一函数,将两个字符串连接 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 343  Solved: 210[Submit][Status][ ...

  5. ytu 1050:写一个函数,使给定的一个二维数组(3×3)转置,即行列互换(水题)

    1050: 写一个函数,使给定的一个二维数组(3×3)转置,即行列互换 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 154  Solved: 112[ ...

  6. ytu 1061: 从三个数中找出最大的数(水题,模板函数练习 + 宏定义练习)

    1061: 从三个数中找出最大的数 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 154  Solved: 124[Submit][Status][We ...

  7. ytu 1059: 判别该年份是否闰年(水题,宏定义)

    1059: 判别该年份是否闰年 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 222  Solved: 139[Submit][Status][Web ...

  8. ytu 1064: 输入三个字符串,按由小到大的顺序输出(水题,字符串处理)

    1064: 输入三个字符串,按由小到大的顺序输出 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 471  Solved: 188[Submit][Sta ...

  9. ytu 2558: 游起来吧!超妹!(水题,趣味数学题)

    2558: 游起来吧!超妹! Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 7  Solved: 3[Submit][Status][Web Board ...

随机推荐

  1. vi显示行号

    vi显示行号   :set nu         带行号查看,并不改变文件内容:set nonu     取消带行号查看在每个用户的主目录下,都有一个 vi 的配置文件".vimrc&quo ...

  2. poj 1067 取石子游戏(威佐夫博奕(Wythoff Game))

    这里不在详细介绍威佐夫博弈论 简单提一下 要先提出一个名词“奇异局势”,如果你面对奇异局势则必输 奇异局势前几项(0,0).(1,2).(3,5).(4,7).(6,10).(8,13).(9,15) ...

  3. struts2 访问国际化资源 <s:text>作为属性

    保留全局级国际化信息资源文件.并在message.properteis中增加一个带有参数的国际化信息. labela = labela in zh_CN labelb = labelb,{0} < ...

  4. linux ls和 ll 命令

    工作中用到      ll -alrth|tail -30    命令 所以再来回顾一下 ls 命令 linux ls和 ll 命令 ll 命令列出的信息更加详细,有时间,是否可读写等信息 ll命令和 ...

  5. Linux的一个问题ircbot进程

    首先该问题目前还不清楚希望知道的人可以回复我mail fengtaotao2012x@163.com 今天执行一次常规服务器安全抽查的时候发现一台web服务器的一个奇怪的进程 而且更厉害的是cpu使用 ...

  6. cf.VK CUP 2015.B.Mean Requests

    Mean Requests time limit per test 4 seconds memory limit per test 256 megabytes input standard input ...

  7. Rescue

    1039: Rescue Time Limit: 1 Sec  Memory Limit: 32 MBSubmit: 1320  Solved: 306 Description Angel was c ...

  8. HDU 4925 Apple Tree(模拟题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4925 解题报告:给你n*m的土地,现在对每一块土地有两种操作,最多只能在每块土地上进行两种操作,第一种 ...

  9. Centos7上使用官方YUM源安装Mysql

    1. 下载mysql的repo源 $ wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm 2. 安装mysql-co ...

  10. 第8章 Iptables与Firewalld防火墙

    章节简述: 红帽RHEL7系统已经用firewalld服务替代了iptables服务,新的防火墙管理命令firewall-cmd与图形化工具firewall-config. 本章节基于数十个防火墙需求 ...