ytu 1910:字符统计(水题)
字符统计
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
Sample Output
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:字符统计(水题)的更多相关文章
- ytu 1998:C语言实验——删除指定字符(水题)
C语言实验——删除指定字符 Time Limit: 1 Sec Memory Limit: 64 MBSubmit: 327 Solved: 211[Submit][Status][Web Boa ...
- 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 ...
- ytu 1304:串的简单处理(水题)
串的简单处理 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 39 Solved: 11[Submit][Status][Web Board] Desc ...
- ytu 1052: 写一函数,将两个字符串连接(水题,指针练习)
1052: 写一函数,将两个字符串连接 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 343 Solved: 210[Submit][Status][ ...
- ytu 1050:写一个函数,使给定的一个二维数组(3×3)转置,即行列互换(水题)
1050: 写一个函数,使给定的一个二维数组(3×3)转置,即行列互换 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 154 Solved: 112[ ...
- ytu 1061: 从三个数中找出最大的数(水题,模板函数练习 + 宏定义练习)
1061: 从三个数中找出最大的数 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 154 Solved: 124[Submit][Status][We ...
- ytu 1059: 判别该年份是否闰年(水题,宏定义)
1059: 判别该年份是否闰年 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 222 Solved: 139[Submit][Status][Web ...
- ytu 1064: 输入三个字符串,按由小到大的顺序输出(水题,字符串处理)
1064: 输入三个字符串,按由小到大的顺序输出 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 471 Solved: 188[Submit][Sta ...
- ytu 2558: 游起来吧!超妹!(水题,趣味数学题)
2558: 游起来吧!超妹! Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 7 Solved: 3[Submit][Status][Web Board ...
随机推荐
- Python socket编程之七:多窗口的应用
f1.py # -*- coding: utf-8 -*- import socket import struct import sqlalchemy import pandas ########## ...
- [LeetCode] Best Time to Buy and Sell Stock III
将Best Time to Buy and Sell Stock的如下思路用到此题目 思路1:第i天买入,能赚到的最大利润是多少呢?就是i + 1 ~ n天中最大的股价减去第i天的. 思路2:第i天买 ...
- Iterator&Vector应用实例
public class test1 { /** * @param args */ public static void main(String[] args) { // TODO Auto-gene ...
- 反射中 GetCustomAttributes
public abstract object[] GetCustomAttributes(bool inherit); 这是GetCustomAttributes方法的一个重载,参数为bool类型返回 ...
- c/c++指针
指针主要分: 指向单一的某个对象/变量, 用于多态或函数指针, 这个不难 - 一级指针 其次是指向数组, 用来操作/遍历数组元素 - 一级/二级指针 指向数组的一级指针很简单了: p指向的是数组的元素 ...
- jQuery1.11源码分析(8)-----jQuery调用Sizzle引擎的相关API
之所以把这部分放在这里,是因为这里用到了一些基本API,前一篇介绍过后才能使用. //jQuery通过find方法调用Sizzle引擎 //jQuery通过find方法调用Sizzle引擎 jQuer ...
- 取地址符:&
例子: <?php $a=10; $b = &$a; echo $b; $b=15; echo $a; //结果:10和15 //当$b = &$a 时,a,b的地址相同,对a, ...
- Button控件常用api
加载按钮的纹理.loadTextures (const std::string &normal, const std::string &selected, const std::str ...
- App架构设计经验谈:服务端接口的设计
App与服务器的通信接口如何设计得好,需要考虑的地方挺多的,在此根据我的一些经验做一些总结分享,旨在抛砖引玉. 安全机制的设计 现在,大部分App的接口都采用RESTful架构,RESTFul最重要的 ...
- The CompilerVersion constant identifies the internal version number of the Delphi compiler.
http://delphi.wikia.com/wiki/CompilerVersion_Constant The CompilerVersion constant identifies the in ...