Loading... OpenAi写的一段代码,太值得学习了 ~~自己写for循环提取小数实在是太蠢了~~ ## copy ```c++ std::copy(start, end, std::back_inserter(container)); std::copy(iterator source_first, iterator source_end, iterator target_start); ``` 因为第三个参数要接受一个迭代器,所以需要使用`back_inserter(container)` ## regex pass ```c++ string expression = "4.12*3.14"; regex pattern("([\\d.]+)|([+\\-*/()])"); vector<string> words; copy( sregex_token_iterator(expression.begin(), expression.end(), pattern), sregex_token_iterator(), back_inserter(words)); for(int i = 0; i < words.size(); i++) cout << words[i] << endl; ``` Last modification:December 6, 2022 © Allow specification reprint Like 0 如果觉得我的文章对你有用,请随意赞赏
Comment here is closed