Pagini recente » test150505.2 | Cod sursa (job #732842) | Cod sursa (job #1186449) | Cod sursa (job #1064464) | Cod sursa (job #151296)
Cod sursa(job #151296)
#include<fstream>
int n,stv[100],j;
using namespace std;
ifstream fin("permutari.in");
ofstream fout("permutari.out");
int tipar()
{
int ii;
for(ii=0;ii<n;ii++)
fout<<stv[ii]<<" ";
fout<<endl;
if(n==0)fout<<"0";
return 0;
}
int back(int k)
{
int cont,i;
if(k==n) tipar();
else for(i=1;i<=n;i++)
{
stv[k]=i;
cont=1;
for(j=0;j<k;j++)
if(stv[k]==stv[j]) cont=0;
if(cont){back(k+1);}
}
return 0;
}
int main()
{
fin>>n;
back(0);
return 0;
}