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("\n");
	} while (next_permutation(a, a + 3));
	
}

OUTPUT:

123
132
213
231
312
321
posted @ 2021-09-03 08:08  小帆敲代码  阅读(5)  评论(0编辑  收藏  举报