1. 提取指定范围符号内用逗号隔开数字
vector<int> trans(string &str){
size_t start = str.find('[');
size_t end = str.find(']');
string numStr = str.substr(start + 1, end - start - 1);
stringstream ss(numStr);
int number;
vector<int> numbers;
while (ss >> number) {
numbers.push_back(number); // 将提取到的数字添加至 vector 容器中
if (ss.peek() == ',')
ss.ignore(); // 忽略逗号分隔符
}
return numbers;
}
标签:提取,ss,number,ACM,start,vector,numbers,str,格式
From: https://www.cnblogs.com/929code/p/17627339.html