题解 | #首字母大写#

首字母大写

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

#include <bits/stdc++.h>

using namespace std;

int main() {
    string scent;

    while (getline(cin, scent)) {
        scent = ' ' + scent;
        for (int i = 1; i < scent.size(); ++i) {
            if ('a' <= scent[i] && 'z' >= scent[i] && (' ' == scent[i - 1] || '\t' == scent[i - 1]) ||
                '\r' == scent[i - 1] || '\n' == scent[i - 1]) {
                scent[i] -= 32;
            }
        }
        printf("%s\n", scent.substr(1, scent.size()).c_str());
    }
    return 0;
}

全部评论

相关推荐

迷茫的大四🐶:价格这么低都能满了?
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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