新博客地址: vonsdite.cn
题目网址: Educational Codeforces Round 26 A. Text Volume
题意分析:
给一个串, 输出串中单词所含的大写字母个数最多的数目一次循环即可
代码:
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
string word;
int n;
while (~scanf("%d", &n))
{
getchar();
getline(cin, word);
int len = (int)word.length();
int cnt = 0, MAX = 0;
for (int i = 0; i < len; ++i)
{
while (i < len && word[i] == ' ')
{
++i;
}
cnt = 0;
while (i < len && word[i] != ' ')
{
if(word[i] >= 'A' && word[i] <= 'Z') ++cnt;
++i;
}
MAX = max(cnt, MAX);
}
printf("%d\n", MAX);
}
return 0;
}