Use next_permutation to permutate a vector of classes

后端 未结 3 1874
[愿得一人]
[愿得一人] 2021-01-12 11:49

Is it possible to use std::next_permutation() to permutate the elements of a vector of a class i created?

How does the comparison parameter in next_permutation() wor

3条回答
  •  -上瘾入骨i
    2021-01-12 11:56

    Is it possible to use std::next_permutation() to permutate the elements of a vector of a class i created?

    Yes!

    Try this

     #include
     #include
     #include
    
    int main()
     {
          typedef std::vector V; //
          V v;
    
          for(int i=1;i<=5;++i)
            v.push_back(i*10);
          do{
                std::cout<

    How does the comparison parameter in next_permutation() work?

    This might help

提交回复
热议问题