题解 | #首字母大写#为啥当初想这么久呢
首字母大写
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")