#include<bits/stdc++.h>
using namespace std;
int i=0,k=0,p=0;
int n;
int a[10];
void f(int begin,int last)
{
int i=0,k=0,p=0;
bool check=true;
if(begin==(last+1))
{
for(i=1;i<=last;i++)
cout<<a[i];
cout<<endl;
return ;
}
for(i=1;i<=last;i++)
{
check=true;
for(k=1;k<begin;k++)
{
if(a[k]==i)
{
check=false;
break;
}
}
if(check==true)
{
a[begin]=i;
f(i+1,last);
a[begin]=0;
}
}
}
int main()
{
memset(a,0,sizeof(a));
cin>>n;
f(1,n);
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/282182.html
標籤:C++ 語言
下一篇:求助
