Educational Codeforces Round 26
You are given a text of single-space separated words, consisting of small and capital Latin letters.
Volume of the word is number of capital letters in the word. Volume of the text is maximum volume of all words in the text.
Calculate the volume of the given text.
The first line contains one integer number n (1 ≤ n ≤ 200) — length of the text.
The second line contains text of single-space separated words s1, s2, ..., si, consisting only of small and capital Latin letters.
Print one integer number — volume of text.
7
NonZERO
5
24
this is zero answer text
0
24
Harbour Space University
1
In the first example there is only one word, there are 5 capital letters in it.
In the second example all of the words contain 0 capital letters.
求一个单词内最多的大写字母个数,遇到空格处理下,最后也处理下
#include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; getchar(); string s; getline(cin,s); int sum=0,f=0; for(int i=0;s[i];i++){ if(s[i]==' '){ if(f>sum)sum=f; f=0; }else if(s[i]<'a')f++; } if(f>sum)sum=f; cout<<sum<<endl; return 0; }
本文来自博客园,作者:暴力都不会的蒟蒻,转载请注明原文链接:https://www.cnblogs.com/BobHuang/p/7283280.html