Run ID:158454

提交时间:2026-08-21 23:25:21

#include <bits/stdc++.h> using namespace std; int main() { int T; cin >> T; cin.ignore(); // 吃掉T后面的换行,非常关键! while(T--) { string line; getline(cin, line); //读取一整行,包含空格 string ans; // flag标记:下一个字符是不是单词的首字母 bool first = true; for(int i = 0; i < line.size(); i++) { char ch = line[i]; if(ch == ' ') { first = true; //遇到空格,后面就是新单词开头 } else { if(first) { //转大写 ans += toupper(ch); first = false; } } } cout << ans << endl; } return 0; }