[Group] title 18NOIP popularity statistics

Description [title]
Kaikai just wrote a wonderful essay, I wonder how many characters in the title of this essay?

Note: The title may contain upper and lower case letters, numbers, characters, spaces and line breaks. When the title character statistics, spaces and line breaks are not counted.

[Enter]
enter only one line, a string s s

[Output]
output only one line containing an integer that is the number of characters essay title (no spaces and line breaks).

[Input] Sample
234
[output] Sample
3
[Note]
[Sample 1] Description

A total of title 3 3 characters, which 3 3 characters are numeric characters.

Sample input [2]

Ca 45
[2] Sample Output

4
[Description] Sample 2

A total of title 5 5 characters, including 1 1 uppercase letters, 1 1 lowercase letters and 2 2 numeric characters, as well as 1 1 spaces. Because spaces are not included in the results, so the effective number of characters for the title 4 4 Ge.

[Agreed] with the scale data

Provision s |s| A string representing the s s length (i.e., the character string and the number of spaces).

For 40% of the data, 1 s 5 1 ≤ |s| ≤ 5 , to ensure that input for the end of the line numeric characters and line breaks.

For 80% of the data, 1 s 5 1 ≤ |s| ≤ 5 , the input may only contain upper and lower case letters, numeric characters and the end of the line newline.

To 100% of the data, 1 s 5 1 ≤ |s| ≤ 5 , the input may contain upper and lower case letters, numbers end characters, spaces, line breaks and line.

#include<bits/stdc++.h>
using namespace std;
long long ans; 
string s;
int main(){
	getline(cin, s);
	int len = s.size();
	for(int i=0; i<len; i++){
		if(s[i] != ' ')
			++ans;
	}
	printf("%lld", ans);
	return 0;
}
Published 15 original articles · won praise 10 · views 206

Guess you like

Origin blog.csdn.net/qq_39053800/article/details/104254022