题解 | 首字母大写
#include <cctype>
#include <iostream>
#include <vector>
#include <string>
using std::cout;
using std::cin;
using std::endl;
using std::vector;
using std::string;
int main() {
string line; // 按行处理
while (std::getline(cin, line)) {
bool flag = true; // 标记本字符前一个字符是否是空白字符
for (auto& elem : line) {
if (flag) {
if (elem >= 'a' && elem <= 'z') {
elem -= 32; // 小写改大写
}
}
if (isspace(elem))
flag = true;
else
flag = false;
}
cout << line << endl;
}
return 0;
}