#include <iostream>
#include <string>
#include <cctype>
using namespace std;
int main() {
string s,a;
getline(cin,s);
bool starttopush=true;
for(auto c : s){
if(starttopush){
a+=toupper(c);
starttopush=false;
}
if (c==' ') {
starttopush=true;
}
}
cout<<a;
}
一个直观的解法。

京公网安备 11010502036488号