全网唯一真预言家
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
using namespace std;
//输入形如[1,2,34,4,-8]的字符串,返回该数组
vector<int> decode(string s) {
s = s.substr(1, s.size() - 2);
stringstream ss(s);
string numS;
vector<int> nums;
while (getline(ss, numS, ',')) {
nums.push_back(stoi(numS));
}
return nums;
}
int main() {
auto r = decode("[1,2,34,4,-8]");
for (auto n : r)
cout << n << ' ';
cout << endl;
return 0;
}