algorithm:next_permutation

输出3的全排列

//输出n的全排列
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
	int a[] = { 1,2,3 };

	do {
		for (int i = 0; i < 3; i++)
		{
			printf("%d",a[i]);
		}
		printf("
");
	} while (next_permutation(a, a + 3));
	
}

OUTPUT:

123
132
213
231
312
321
原文地址:https://www.cnblogs.com/code-fun/p/15221545.html