#Snow{ position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 99999; background: rgba(255,255,240,0.1); pointer-events: none; }

next_permutation prev_permutation

next_permutation () 是按照字典升序的方式生成的排列。
prev_permutation () 是按照字典将序的方式生成的排列。

求1~n的全排列

	cin>>n;
	for(int i=1;i<=n;i++) a[i]=i,num*=i;
	for(int i=1;i<=num;i++)
	{
		for(int i=1;i<=n;i++)
		{
			cout<<"    "<<a[i];
		}
		printf("\n");
		next_permutation(a+1,a+1+n);
	}
posted @ 2022-10-10 07:26  繁花孤城  阅读(32)  评论(0)    收藏  举报