C全排列问题

#include <iostream>
using namespace std;

void Perm(int list[],int k,int m)
{
	if(k==m)
	{
		for(int i=0;i<=m;i++)
			cout<<list[i]<<" ";
		cout<<endl;
	}
	else
		for(int j=k;j<=m;j++)
		{
			swap(list[k],list[j]);
			Perm(list,k+1,m);
			swap(list[k],list[j]);
		}
}

int main()
{
	int list[]={1,2,3,4,5,6};
	Perm(list, 0, 3);
	return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_40330033/article/details/82770094
今日推荐