C++刷题常用转换
#include <iostream>
#include <string>
#include <sstream> // 头文件
#include <algorithm>
#include <vector>
using namespace std;
int main(){
string s1;
string str = s1 + " a1 b1 c2 d4 h5s s " + " aogj";
stringstream ss(str); // 把str输入到字符流中,按照空格进行分割的
vector<string> words;
string word;
while(ss >> word) { // 把单词一个一个的输出给word
words.push_back(word);
}
for (auto &item: words) {
cout << item << endl;
}
}