题解 | #首字母大写#
首字母大写
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")