题解 | #首字母大写#为啥当初想这么久呢

首字母大写

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

#include <iostream>
#include <string>
using namespace std;

char arr[200];

int main() {
    string str;
    while (fgets(arr, 200, stdin)) {
        str = arr;
        if (str[0] >= 'a' && str[0] <= 'z') {
            str[0] -= 32;
        }
        for (int i = 1; i < str.size(); i++) {
            if (str[i - 1] == ' ' || str[i - 1] == '\t' ||
                    str[i - 1] == '\n' || str[i - 1] == '\r') {
                if (str[i] >= 'a' && str[i] <= 'z') {
                    str[i] -= 32;
                }
            }
        }
        printf("%s\n", str.c_str());
    }

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

全部评论

相关推荐

不愿透露姓名的神秘牛友
06-25 17:22
点赞 评论 收藏
分享
舂锋:不能投什么岗都用一份简历,一般都是要看企业的岗位需求来写职业技能或者是项目经历,跟岗位相关的就写多一点。
点赞 评论 收藏
分享
后来123321:别着急,我学院本大二,投了1100份,两个面试,其中一个还是我去线下招聘会投的简历,有时候这东西也得看运气
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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