解法一
✅ 完整代碼
評分結果(參考) : AC (2ms, 324KB)
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
string s;
while(getline(cin, s)){
int i=0;
for(; i<s.size()-1; i++){
if((s[i+1]==' ' || i==0) && s[i]==' ') cout << "*";
else cout << s[i];
}
if(s[i] == ' ') cout << "*\n";
else cout << s[i] << "\n";
}
return 0;
}