其他分享
首页 > 其他分享> > 递归求数组全排

递归求数组全排

作者:互联网

#include<iostream>
using namespace std;
#include<string>
int arry[10] = { 1,2,3,4,5,6,7,8,9,10 };
int hash_arry[10] = { 0 };
int mark_arry[10] = { 0 };
int c=0;
int index = 0;
void creat()
{
	if (index >= 10)
	{
		c++;
		return;
	}
	for (int i = 0; i < 10; i++)
	{
		if (mark_arry[i] == 0)
		{
			mark_arry[i] = 1;
			hash_arry[index++] = arry[i];
			creat();
			index--;
			mark_arry[i] = 0;

		}
	}

}
int main()
{
	creat();
	cout << c;
}

标签:10,creat,递归,index,全排,mark,int,数组,arry
来源: https://blog.csdn.net/weixin_45754140/article/details/110941259