题解 | #首字母大写#

首字母大写

https://www.nowcoder.com/practice/91f9c70e7b6f4c0ab23744055632467a

#include <bits/stdc++.h>
using namespace std;

int main() {
    string s;
    while (getline(cin, s)) {
        if (s[0] >= 'a' && s[0] <= 'z')
            s[0] = s[0] - 32;
        int len = s.size();
        for (int i = 1; i < len; i++) {
            if (s[i] == ' ' || s[i] == '\t' || s[i] == '\r' || s[i] == '\n') {
                if (s[i + 1] >= 'a' && s[i + 1] <= 'z') {
                    s[i + 1] -= 32;
                }
            }
        }
        cout<<s<<endl;

    }
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

mjasjon:这种trash中厂 简历过筛概率比大厂还低(除阿里系)
投递哔哩哔哩等公司6个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务