Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/135.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
是否有一种STL方法来查找字符串的所有排列,并以C+表示大小+;? 什么是找到C++中大小指定的字符串的所有排列的最好方法?我正在从Python进行转换,并且想知道C++是否有一个可以做这个的构建器,或者我必须从头开始实现。在Python中,我只需要这样做 import itertools print(list(itertools.permutations(string,size))_C++_Stl - Fatal编程技术网

是否有一种STL方法来查找字符串的所有排列,并以C+表示大小+;? 什么是找到C++中大小指定的字符串的所有排列的最好方法?我正在从Python进行转换,并且想知道C++是否有一个可以做这个的构建器,或者我必须从头开始实现。在Python中,我只需要这样做 import itertools print(list(itertools.permutations(string,size))

是否有一种STL方法来查找字符串的所有排列,并以C+表示大小+;? 什么是找到C++中大小指定的字符串的所有排列的最好方法?我正在从Python进行转换,并且想知道C++是否有一个可以做这个的构建器,或者我必须从头开始实现。在Python中,我只需要这样做 import itertools print(list(itertools.permutations(string,size)),c++,stl,C++,Stl,这就是我试图模仿的功能。如果您能提供任何帮助,我们将不胜感激。除了没有大小参数的下一个排列之外,我们实在找不到任何其他东西。不仅是STL,而且非常简单: std::string s = ...; std::sort(s.begin(), s.end()); // to know when you've been through all permutations std::vector<std::string> v; // v.reserve(boost::math::factoria

这就是我试图模仿的功能。如果您能提供任何帮助,我们将不胜感激。除了没有大小参数的下一个排列之外,我们实在找不到任何其他东西。

不仅是STL,而且非常简单:

std::string s = ...;
std::sort(s.begin(), s.end()); // to know when you've been through all permutations
std::vector<std::string> v; // v.reserve(boost::math::factorial(s.size());
do {
    v.push_back(s); // or process in-place
} while (std::next_permutation(s.begin(), s.end());
std::string s=。。。;
排序(s.begin(),s.end());//知道你什么时候经历了所有的变化
std::向量v;//v、 保留(boost::math::factorial(s.size());
做{
v、 向后推_;//或在适当的位置进行处理
}while(std::next_置换(s.begin(),s.end());

不仅仅是STL,而且它非常简单:

std::string s = ...;
std::sort(s.begin(), s.end()); // to know when you've been through all permutations
std::vector<std::string> v; // v.reserve(boost::math::factorial(s.size());
do {
    v.push_back(s); // or process in-place
} while (std::next_permutation(s.begin(), s.end());
std::string s=。。。;
std::sort(s.begin(),s.end());//了解您何时完成了所有排列
std::vector v;//v.reserve(boost::math::factorial(s.size());
做{
v、 向后推_;//或在适当的位置进行处理
}while(std::next_置换(s.begin(),s.end());

<代码>大小>什么是“大小指定的字符串”?C++中没有这样的“内置”。你可以给你整字符串的排列,但是没有什么可以给你所有大小的排列:<代码> n>代码>。Holt,我是通过STL来表示的。但是听起来不错,谢谢!看,什么是“按大小指定的字符串”?没有这样的“内置”。在C++中,你可以给你整串的排列,但是没有什么能给你所有的排列大小:<代码> n>代码> @ Holt,我是指通过STL。但是听起来不错,谢谢!但是最好是在原地做工作而不是返回(大/大)。vector。@Jarod42同意。我想让它与上面的列表具有相同的效果,但就地将更加有效,但可能更好的做法是就地完成工作,而不是返回(大/大)vector。@Jarod42同意。我想让它与上面的列表具有相同的效果,但就地将更加有效