codeforces 837A

来源:互联网 发布:知乎赞同和感谢 编辑:程序博客网 时间:2024/05/17 01:22
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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.

Input

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.

Output

Print one integer number — volume of text.

Examples
input
7
NonZERO
output
5
input
24
this is zero answer text
output
0
input
24
Harbour Space University
output
1
Note

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;char s[205];int main(){    int n;    scanf("%d",&n);    getchar();    //gets(s);    scanf("%[^\n]", s);//意思是读取到换行结束,但是前面有输入,先用getchar过滤掉换行使用gets也一样要用getchar
//其他方法:while(~scanf("%s",s))一个串的读入进去操作,do while循环也一样,读取到'\n'结束就可以了,还可以用getchar单个字符读入    int num=0,ans=0;    for(int i=0;i<n;i++)    {        if(s[i]==' ')        {            num=0;            continue;        }        if(s[i]>='A'&&s[i]<='Z')        {            num++;        }        ans=max(ans,num);    }    printf("%d\n",ans);}

原创粉丝点击