cb48a_c++_STL_算法_重排和分区random_shuffle_stable_partition
random_shuffle()//重排,随机重排,打乱顺序
partition()分区,把符合规则的分成两个区域,比如奇数放一边,偶数放一边.默认之间的位置会变化
stable_partition(),稳定的分区,分区后,默认之间的位置不会变化,
比如:2,3,5,6,分区后,2依然在6的前面。3依然在5的前面
STL算法--变序性算法
reverse() 逆转
reverse_copy()一边复制一般逆转
rotate()旋转,某个位置开始前后交换位置
rotate(ivec2.begin(), ivec2.begin() + 2, ivec2.end());
1,2,3,4,5,6,7,8,9,
rotate后:
3,4,5,6,7,8,9,1,2,
rotate_copy()一边复制一般旋转
、、、
next_permutation()
prev_permutation()
random_shuffle()
partition()
stable_partition()
/*cb48a_c++_STL_算法_重排和分区random_shuffle_stable_partition
random_shuffle()//重排,随机重排,打乱顺序
partition()分区,把符合规则的分成两个区域,比如奇数放一边,偶数放一边.默认之间的位置会变化
stable_partition(),稳定的分区,分区后,默认之间的位置不会变化,
比如:2,3,5,6,分区后,2依然在6的前面。3依然在5的前面
STL算法--变序性算法
reverse() 逆转
reverse_copy()一边复制一般逆转
rotate()旋转,某个位置开始前后交换位置
rotate(ivec2.begin(), ivec2.begin() + 2, ivec2.end());
1,2,3,4,5,6,7,8,9,
rotate后:
3,4,5,6,7,8,9,1,2,
rotate_copy()一边复制一般旋转
、、、
next_permutation()
prev_permutation()
random_shuffle()
partition()
stable_partition()
*/
#include
#include
#include
#include
using namespace std;
template < typename TT5>
void print1(TT5 &ilist)
{
for (TT5::iterator iter = ilist.begin(); iter != ilist.end(); ++iter)
{
cout
1665060526
查看更多评论