Educational Codeforces Round 26 A. Text Volume

来源:互联网 发布:周笔畅的淘宝店 编辑:程序博客网 时间:2024/06/05 06:02

题目网址: 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;}
原创粉丝点击