Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
109090 汤奕硕 词组缩写 C++ Accepted 1 MS 268 KB 684 2025-01-26 16:21:14

Tests(1/1):


Code:

#include <iostream> #include <sstream> #include <cctype> // 用于字符操作 using namespace std; int main() { int T; cin >> T; // 读取测试数据组数 cin.ignore(); // 忽略换行符,确保下一次读取时从第一组数据开始 while (T--) { string line; getline(cin, line); // 读取整行输入 stringstream ss(line); string word; string abbreviation; while (ss >> word) { // 逐个读取单词 abbreviation += toupper(word[0]); // 提取单词的首字母并转换为大写 } cout << abbreviation << endl; // 输出缩写 } return 0; }