解法一、stringstream
✅ 完整代碼
評分結果(參考) : AC (2ms, 344KB)
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string names, greeting, temp;
    getline(cin, names);
    getline(cin, greeting);
    
    stringstream ss(names);
    
    while(ss >> temp){
        cout << greeting << ", " << temp << "\n";
    }
    
    return 0;
}