题解 | #统计大写字母个数#

统计大写字母个数

http://www.nowcoder.com/practice/434414efe5ea48e5b06ebf2b35434a9c

#include <iostream>
#include <string>

using namespace std;

int main()
{
    //input
    string str;
    //result
    int result = 0;
    while(getline(cin, str))
    {
        int length = str.length();
        for(int i=0; i<length; i++)
        {
            if(str[i] - 'A' >= 0 && 'Z'-str[i] >= 0)
            {
                result ++;
            }
        }
        cout<<result<<endl;
        result = 0;
    }

    //return
    return 0;
}
全部评论

相关推荐

用微笑面对困难:这里面最强的是驾驶证了,可以入职美团大厂,然后直接开启黄马褂人生
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务