草了个DJ,怎么一直记不住这个啊!
#include<iostream>
#include<sstream>
using namespace std;
int main(){
string str;
getline(cin, str);
string x;
stringstream ss(str);
while(ss >> x){
cout << x << endl;
}
}
也可以这样:
#include <iostream>
#include<vector>
using namespace std;
int main () {
vector<string> strVector;
string tmp;
while(cin>>tmp){
strVector.push_back(tmp);
if(cin.get()=='\n'){
// do something
}
}
}