#45503: 這題用stringstream 超級簡單!!!!!!!


1121228@stu.wghs.tp.edu.tw (你知道我是誰嗎!!??)


stringstream基本上就是個容器 他以字為單位儲存 所以都幫你分割好字了!

#include <bits/stdc++.h>
using namespace std;
 
int main() {
string s;
getline(cin, s);
stringstream ss(s);
string t;
ss >> t;
cout << t;
while(ss >> t){
    cout << " little, " << t;
}
cout << " little Indians";
    return 0;
}
#55364: Re: 這題用stringstream 超級簡單!!!!!!!


u210630@tcivs.tc.edu.tw (xiulan)


直接cin也可以

int main(){
    string s;
    cin >> s;
    printf("%s", s.c_str());
    while(cin >> s){
        printf(" little, %s", s.c_str());
    }
    printf(" little Indians\n");
}

 

#55384: Re: 這題用stringstream 超級簡單!!!!!!!


kenny980721.tu@gmail.com (有事直接私)


寫這樣就可以
#include<bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;
    cout << s << " little";
    while(cin >> s) cout << ", " << s << " little";
    cout << " Indians";
    
    return 0;
}