算法:STL全排列next_permutation()函数的用法

int a[];
do
{
}while( next_permutation(a , a + n);

#include <bits/stdc++.h>
using namespace std;
int n;
int main()
{
	int a[4] ={1,3,2};
	sort( a ,a + 3);
	do
	{
		for(int i = 0;i<3 ;i++)
		     cout<<a[i]<<" ";
		     puts("");
		
	}while(next_permutation(a , a + 3));
	return 0;
} 

运行结果如下:
算法:STL全排列next_permutation()函数的用法

上一篇:LeetCode-0031. Next Permutation


下一篇:LeetCode - 解题笔记 - 60 - Permutation Sequence