题解 | #首字母大写#

首字母大写

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

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

bool isBlank(char c){
    if(c == ' ' || c == '\t' || c == '\r' || c == '\n')return 1;
    return 0;
}

int main() {
    string s;
    while(getline(cin,s)){
        for(int i =0;i<s.length();i++){
            if(islower(s[i])){
                if(i == 0 || isBlank(s[i-1]))
                    s[i] -= 'a'-'A';
            }
        }
        cout<<s<<endl;
    }
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

头像
04-09 14:29
Java
点赞 评论 收藏
转发
点赞 收藏 评论
分享
牛客网
牛客企业服务