解法:
看字符串首元素即可
#include<iostream>
#include<vector>
#include<string>
#include<sstream>
using namespace std;
#define endl '\n'
void solve() {
cin >> ws;
string s, str;
getline(cin, s);
stringstream ss(s);
while (ss >> str) {
if (str[0] >= 'a' && str[0] <= 'z') {
continue;
}
else {
int flag = 0;
for (int i = 0; i < str.size(); i++) {
if (str[i] >= 'a' && str[i] <= 'z') {
flag = 1;
break;
}
}
if (flag) {
cout << str[0];
}
else {
cout << str;
}
}
}
}
int main() {
int t; cin >> t;
while (t--) {
solve();
cout << endl;
}
return 0;
}