题目描述
算算以 '.' 结束的一串字符中含有多少个大写的英文字母。
输入
输入一串字符(长度不超过 8080 ),以 '.' 结束。
输出
输出一行,即这串字符中大写字母的个数。
样例输入
PRC,PRC,I'm from China.
样例输出
8
AC代码
#include<bits/stdc++.h>
using namespace std;
int main(){
int c=0;
string s;
getline(cin,s);
for(int i=0;i<s.size();i++){
//这里运用一个最普通的if遍历
//同时也可以使用isupper()函数来遍历大写字母
//if(isupper(s[i])) c++;
if(s[i]>='A' && s[i]<='Z') c++;
}
cout<<c;
return 0;
}


