2443: 【入门】【P5015】标题统计

内存限制:128 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:33 解决:19

题目描述

凯凯刚写了一篇美妙的作文,请问这篇作文的标题中有多少个字符? 注意:标题中可能包含大、小写英文字母、数字字符、空格和换行符。统计标题字 符数时,空格和换行符不计算在内。

输入

输入文件只有一行,一个字符串 lns="http://www.w3.org/1998/Math/MathML">

输出

输出文件只有一行,包含一个整数,即作文标题的字符数(不含空格和换行符)。

样例输入 复制

234 

样例输出 复制

3

提示


输入 #2
Ca 45 
输出 #2
4


【输入输出样例 1 说明】
标题中共有 3 个字符,这 3 个字符都是数字字符。

【输入输出样例 2 说明】 标题中共有lns="http://www.w3.org/1998/Math/MathML">5 个字符,包括 lns="http://www.w3.org/1998/Math/MathML">1 个大写英文字母, lns="http://www.w3.org/1998/Math/MathML">1 个小写英文字母和 lns="http://www.w3.org/1998/Math/MathML">2 个数字字符, 还有 lns="http://www.w3.org/1998/Math/MathML">1 个空格。由于空格不计入结果中,故标题的有效字符数为 lns="http://www.w3.org/1998/Math/MathML">4 个。

【数据规模与约定】
规定 lns="http://www.w3.org/1998/Math/MathML"> 表示字符串 lns="http://www.w3.org/1998/Math/MathML"> 的长度(即字符串中的字符和空格数)。
对于 lns="http://www.w3.org/1998/Math/MathML">40% 的数据,lns="http://www.w3.org/1998/Math/MathML">15,保证输入为数字字符及行末换行符。
对于 lns="http://www.w3.org/1998/Math/MathML">80% 的数据,lns="http://www.w3.org/1998/Math/MathML">15,输入只可能包含大、小写英文字母、数字字符及行末换行符。
对于 lns="http://www.w3.org/1998/Math/MathML">100% 的数据,lns="http://www.w3.org/1998/Math/MathML">15,输入可能包含大、小写英文字母、数字字符、空格和行末换行符。

标准输入输出:

#include<bits/stdc++.h>
using namespace std;

int main(){
    string s;
    int ans=0;
    while (cin>>s)
        ans +=s.length();
    cout<<ans<<endl;
	return 0;
}

文件输入输出: