私が持っているc++ vectorとstd::pair<unsigned long, unsigned long>、オブジェクト。私はを使用してベクトルのオブジェクトの順列を生成しようとしていますstd::next_permutation()。ただし、permutations予想される返される順列のサイズが指定されているpython の関数と同様に、順列を特定のサイズにする必要があります。
基本的には、c++同等の
import itertools
list = [1,2,3,4,5,6,7]
for permutation in itertools.permutations(list, 3):
    print(permutation)
(1, 2, 3)                                                                                                                                                                            
(1, 2, 4)                                                                                                                                                                            
(1, 2, 5)                                                                                                                                                                            
(1, 2, 6)                                                                                                                                                                            
(1, 2, 7)                                                                                                                                                                            
(1, 3, 2)
(1, 3, 4)
..
(7, 5, 4)                                                                                                                                                                            
(7, 5, 6)                                                                                                                                                                            
(7, 6, 1)                                                                                                                                                                            
(7, 6, 2)                                                                                                                                                                            
(7, 6, 3)                                                                                                                                                                            
(7, 6, 4)                                                                                                                                                                            
(7, 6, 5) 
                  そのPythonデモを追加してくれて@ Jarod42に感謝します:)
                
                
                  
                    —
                    d4rk4ng31 
                    
                  
                
              
                  私はpythonの結果がわからないので、私の側でそれをしなければなりませんでしたが、C ++でそれを行う方法を知っているとかなり確信していました。
                
                
                  
                    —
                    Jarod42 
                    
                  
                
              
                  補足として、重複した入力をどのように処理し
                
                  
                    —
                    Jarod42 
                    
                  
                
              (1, 1)ますか?Pythonの順列は重複を提供しますが[(1, 1), (1, 1)]、重複はstd::next_permutation避けます(のみ{1, 1})。
                
                  ええと。重複なし
                
                
                  
                    —
                    d4rk4ng31