HackerRank

这里写图片描述

思路
找单词
第一个 单词 是小写
然后 后面的单词 第一位 都是大写
刚开始 初始化 ans = 1
然后 往后遍历
碰到 大写的 更新答案

AC代码

#include <cstdio>
#include <cstring>
#include <ctype.h>
#include <cstdlib>
#include <climits>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <stack>
#include <set>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <limits>

using namespace std;
typedef long long LL;

const double PI  = 3.14159265358979323846264338327;
const double E   = 2.718281828459;
const double eps = 1e-6;

const int INF = 0x3f3f3f3f;
const int maxn = 1e5 + 5;
const int MOD  = 1e9 + 7;

int main()
{
    string s;
    cin >> s;
    int len = s.size();
    LL ans = 1;
    for (int i = 0; i < len; i++)
    {
        if (s[i] >= 'A' && s[i] <= 'Z')
            ans++;
    }
    cout << ans << endl;
} 
原文地址:https://www.cnblogs.com/Dup4/p/9433256.html